Lightweight Alternative to Sammy.js

Is there a small structure that provides hash / url handling similar to sammy.js? I need to bind callbacks to routes - not only for “regular” receive requests, but also for sending messages / sending / deleting (both are triggered by links / forms or manually from my code).

This is pretty much the case, and since I already use some other frameworks / libraries like jQuery and knockout.js, I don’t want to include a framework like Sammy (which provides too many functions that I am not going to use).

+8
javascript
source share
6 answers

I was not able to find a good solution for this task, so I wrote a very tiny component that does the job for me (and nothing more).

It is called Simrou and can be forked at https://github.com/buero-fuer-ideen/Simrou

+9
source share

History.js .

History.js elegantly supports HTML5 history / status APIs (pushState, replaceState, onPopState) in all browsers. Including ongoing support for data, names, replaceState. Supports jQuery, MooTools and Prototype. For HTML5 browsers, this means that you can change the URL directly, without having to use hashes. For HTML4 browsers, it will revert to using the old onhashchange function.

+7
source share

You can use pager.js. Its a really cool java script library, with which you can also assign your page title, and this will help you deal with the handling of hashes / URLs.

Visit pagerjs.com

+4
source share

For completeness, I thought I mentioned crossroads.js , which I only tried as part of Steve Sander's Yeoman Knockout Generator .

It looks elegant, but I will be grateful for examples . In particular, I did not get any search results for "crossroads.js login" or "crossroads.js auth" :(

Crossroads.js is a routing library based on the Route / Dispatch URL utilities found in frameworks such as Rails, Pyramid, Django, CakePHP, CodeIgniter, etc. It parses the input of the string and decides what action should be performed, the string against multiple patterns.

This is a powerful and flexible routing system. When used correctly, it can reduce code complexity by decoupling objects, as well as by abstracting navigation paths and server requests.

+3
source share

Perhaps you can use the deep link using the jQuery address plugin .

+2
source share

Another option that only does routing, and skips patterns, etc., is Davis.js, see http://davisjs.com/ . Only jQuery dependency.

+2
source share

All Articles