Backbone effective pushState extension

Backbone allows pushState activation that permits usage of real URLs instead of # anchors. PushState offers a better navigation experience, better indexation and search engine ranking:

Backbone.history.start({pushState:true, root:"/"});

The root option defines the path context of our Backbone application;

However, Backbone stops here. Direct access to views by URL works fine but, each link leads to a full reload! Backbone does not intercept html links events and it is necessary to implement it ourselves.

Tim Branyen, the creator of Backbone boilerplate shares the following solution that RESThub integrates in its extensions with an additional test to check pushState activation.

If Backbone.history is started with the pushState option, any click on a link will be intercepted and bound to a Backbone navigation instead. If you want to provide external links, you only have to use the data-bypass attribute:

<a data-bypass href="http://github.com/bmeurant/tournament-front" target="_blank">