Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7604877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:01:25+00:00 2026-05-31T00:01:25+00:00

Here is my application-router.js file where i’m creating Backbone.Router object with just only few

  • 0

Here is my application-router.js file where i’m creating Backbone.Router object with just only few routes:

var App = App || {};

App.Router =  Backbone.Router.extend({
    routes : {
        ''      : 'showDashboard', // Not shown
        '*other': 'showModalError'
    },
    defaultRoute : function(other) { $('#modal404').modal(); }
});

In main javascript file application.js i’d like to programmatically add routes. I’ve tried with route() function and it doesn’t work, routes are not added. It works however passing an object to the “constructor”, but that will override already defined routes:

// This works and overrides all defined routes in App.Router
var router = new App.Router({ routes : { '/test/me' : 'testRoute' } });

// This is not working
router.route(ExposeTranslation.get('customers.new.route'), 'newCustomer');
router.route('/test/me/again', 'testAgainRoute');

In fact console.log(App.Router) shows:

routes Object { /test/me="testRoute"}

I suppose i’m missing something i can’t figure out, i’m beginning learning this little piece of powerful javascript.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:01:26+00:00Added an answer on May 31, 2026 at 12:01 am

    Your router.route calls are working, those calls aren’t your problem. When you call route to add a new route, the new route goes at the end of the routing list. In particular, the routes that are added by your route calls go after '*other' and '*other' will match anything so your new routes will be effectively ignored.

    Try removing your '*other' route from routes and adding it after your two route() calls:

    routes : {
        ''      : 'showDashboard' // Not shown
    },
    
    router.route(ExposeTranslation.get('customers.new.route'), 'newCustomer');
    router.route('/test/me/again', 'testAgainRoute');
    router.route('*other', 'showModalError');
    

    The routes aren’t stored in App.Router object, they’re stored inside Backbone.history:

    route: function(route, name, callback) {
      // ...
      Backbone.history.route(route, _.bind(function(fragment) {
        //...
      }, this));
      return this;
    },
    

    That’s why your console.log(App.Router) doesn’t say anything helpful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my situation: I have an application that use a configuration file. The
I just started learning RoR. This is my /app/trip_controller.rb file class TripController < ApplicationController
I have windows forms application wich runs another console application here is the part
From My Previous question sending request to apple - from iphone custom application Here,
Here's my Application_OnError event sink in global.asax.vb: Sub Application_OnError(ByVal sender As Object, ByVal e
I'm currently using the validation code listed here in an application. I'd like to
Here's the scenario: A C# Windows Application project stored in SVN is used to
Here is a simplified version of my application showing what I'm doing. /* in
Here at work we have a very large application with multiple sub applications. (500
here is a good question: I have an application compiled for iPhone OS 2.21.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.