Backbone.RouteNotFound banner
STRML STRML

Backbone.RouteNotFound

Development community

Description

Simple plugin that fires an event to let the application know that no routes matched, so you can fire a custom 404 handler.

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

backbone.routeNotFound

Simple plugin that fires an event to let the application know that no routes matched, so you can fire a custom 404 handler.

Install

Include backbone.routeNotFound after backbone.js and underscore.js.

If you're using any plugins that override Backbone.history.prototype.loadUrl, include this plugin *after* those plugins to ensure changes to loadUrl are not overwritten.

Usage

A example bit of code to redirect on an invalid route:

// router.js

// ...

initialize: function(){
  this.listenTo(Backbone.history, 'routeNotFound', this.onRouteNotFound);
},

onRouteNotFound: function(){
  console.log("Route not found, redirecting...");
  Backbone.history.navigate('', {trigger: true});
}
 
// ...