Extends backbone.js with path and params
JavaScript
Latest commit 1f17d98 May 3, 2012 @rtsinani add comments
Permalink
Failed to load latest commit information.
test
vendor
README.md update README Apr 10, 2012
colonne.js add templated views May 3, 2012
colonne.view.js

README.md

Colonne

Colonne extends Backbone.History by exposing two extra, and often necessary properties: path and params.

Ported from sammy.js.

Usage

Just add the script after backbone.js, and the functionality should be ready to use.

Let's say, you navigate to a URL fragment /products/search?names=apple&names=nectarine&page=1 you can then call:

// URL fragment: /products/search?names=apple&names=nectarine&page=1

Backbone.history.path               // 'products/search'
Backbone.history.params['names']    // ['apple', 'nectarine']
Backbone.history.params['page']     // '1'

Navigate With

You can also use Backbone.history.navigateWith to go to a path with a query string.

Backbone.history.navigateWith('/products/search', { names: ['apple', 'nectarine'], page: 1 }, {trigger: true});
Backbone.history.fragment   // 'products/search?names=apple&names=nectarine&page=1');

Tests

Colonne passes all Backbone tests for the router, copied at test/router.js. The new functionality is tested at the end of the same file.

Dependencies

Underscore 1.3.1 Backbone 0.9.2

License

Colonne is covered by the MIT License