Last active
December 17, 2015 16:39
-
-
Save ssafejava/5640593 to your computer and use it in GitHub Desktop.
Add 'routeNotFound' event to Backbone.History.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var oldLoadUrl = Backbone.History.prototype.loadUrl; | |
_.extend(Backbone.History.prototype, { | |
/** | |
* Override loadUrl & watch return value. Trigger event if no route was matched. | |
* @return {Boolean} True if a route was matched | |
*/ | |
loadUrl : function() { | |
var matched = oldLoadUrl.apply(this, arguments); | |
if(!matched){ | |
this.trigger('routeNotFound', arguments); | |
} | |
return matched; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment