Skip to content

edorcutt/kquery-hashchange

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

kQuery hashchange

This is a port of jquery-hashchange to the Kynetx Rules Language. Many thanks to Phil Windley for describing how to build a single page interface in KBlog: Making the Back Button Work.

The primary purpose of this module is to provide an evented controller for navigation within a single page interface.

Using the Module

The hashchange module has been placed in the Kynetx Public Module Directory. To use the module add the following use module pragma to the meta section of your ruleset:

meta {
  ...
  use module a169x567
}

Actions

init()

Load the jQuery plugin that provides an interface to browser hashchange events.

rule page_init {
  select when pageview ".*"
		a169x567:init();
}

setHash()

Set a new URL hashtag.

rule sitenav_login_complete {
  select when explicit login_complete
  {
    siteNav:setHash"/myprofile");
  }
}

setActiveNav()

Since I have been spending a lot of time with Twitter Bootstrap lately this action was included. This sets the active navbar.

rule sitenav_about {
  select when web hash_change newhash "/about$"
  {
    siteNav:setActiveNav("#navAbout");
  }
}

Note: The selector can be any valid jQuery selector.

showPanel()

Likewise this action has been included to as a result of my work with Twitter Bootstrap. This displays a specific section of the document, while hiding all of the other sections.

rule sitenav_about {
  select when web hash_change newhash "/about$"
  {
    siteNav:setActiveNav("#navAbout");
    siteNav:showPanel("#sectionAbout");
  }
}

Note: The selector can be any valid jQuery selector.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published