API Docs for: 0.13.12
Show:

Router.Hashbang Class

Defined in: src\firebrick.js:2384
Module: Firebrick

Item Index

Properties

Methods

getRoute

() Object

Returns:

Object:

{ href: "http://localhost/#/mypath/dayone?user=1", origin: "http://localhost" path: "/#/mypath/dayone?user=1", // (href - origin) cleanPath: "/mypath/dayone", //non hash routes hash: "#/mypath/dayone?user=1", //window.location.hash cleanHash: "#/mypath/dayone" parameters:{} //url parameter as object }

getUrlParam

(
  • url
)

Parameters:

  • url String

    /#/mypath/dayone?user=1&name=fred

init

()

call this after setting router.set({}) if you wish to do an immediate evaulation of url

is

(
  • pattern
)
Boolean

Check whether the url matches a pattern - removes any parameters in the url to check for a match

Parameters:

  • pattern String

Returns:

Boolean:

Example:

    Firebrick.router.is("#/completed") // returns true or false
    Firebrick.router.is("/completed") // returns true or false

onHashChange

(
  • callback
  • config
)
Object private

Call a function when the hash changes on the site use Firebrick.route:set

Parameters:

  • callback Function
  • config Object

    config that was used for this callback - optional

Returns:

Object:

jQuery object

Example:

                   Firebrick.router.onHashChange(function(){
                       //something happens
                   })

set

(
  • routes
)

set route definitions

Parameters:

  • routes Object | Function
    • if function then the function is called regardless of route

Example:

    Firebrick.router.set({
        "users/abc": {
            require:["file1", "file2"],
            callback: function(){}
        },
        "contact": function(){}
        defaults: function(){}        //defaults pattern - fallback
    })
    Firebrick.router.set(function(){}) //call function regardless of route

Properties

_initialised

Boolean

used to see whether document events for the history API have already been set

Default: false