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 8321543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:03:23+00:00 2026-06-08T23:03:23+00:00

I have a router setup like so: var AppRouter = Backbone.Router.extend({ routes: { /agents/:id:

  • 0

I have a router setup like so:

var AppRouter = Backbone.Router.extend({
    routes: {
        "/agents/:id": "getAgent",
        "/orders/:id": "getOrders",
        "/users/:id": "getUsers",
        '*path':  'defaultRoute'

    },
    getAgent: function(id) {
        ticketList.url = "/index.php/tickets/viewJSON/a"+id;
    },
    getOrders: function(id) {
        ticketList.url = "/index.php/tickets/viewJSON/o"+id;
    },
    getUsers: function(id) {
        ticketList.url = "/index.php/tickets/viewJSON/u"+id;
    },
    defaultRoute: function() {
        //(here needs to be  the code)   
    }

});

I’m using codeigniter, so when I visit /index.php/agents/view/1103 I need to force the ticketList.url to be /index.php/tickets/viewJSON/a1103 – the a is taken from /agent/ (this will change between user, agent and order, u,a and o respectively, and then the ID taken from whatever trails the view section of the URL.

Whats the best way to get the default route to take these paramaters from the URL? Literally splitting document.URL?

  • 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-06-08T23:03:25+00:00Added an answer on June 8, 2026 at 11:03 pm

    It would be easier to read if you consolidated your three custom routes to one custom route, instead of putting them all in the default.

    var AppRouter = Backbone.Router.extend({
        routes: {
            "/:resource/:id": "getResource"
        },
    
        getResource: function(resource, id) {
            ticketList.url = "/index.php/tickets/viewJSON/" + resource[0] + id;
        }
    });
    

    But note that this will match a lot of different URLs, possibly more than you really want. It might be a better idea to have separate routes for each resource, and just map them all the the same function.

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

Sidebar

Related Questions

I have a router like this, as main entry point: window.AppRouter = Backbone.Router.extend({ routes:
I have a Backbone Router: class X.Routers.Main extends Backbone.Router routes: '/': 'home' 'pageb': 'actionb'
I'd like to call Backbone's router.navigate and have it update the hash fragment only,
In my global.asax I have url routing setup like below: routes.MapPageRoute(User Logon, {Vendor}/Logon, ~/Logon.aspx);
I have 2 models that I would like to setup routes for: Apps and
I'd like to have a route setup like the following routes.MapRoute( Static content handler,
I'm using Rails 3 with Devise and have setup my routes.rb file like so:
I have some routes setup in my global.asax.cs file like this: routes.MapHttpRoute( name: ColorsRoute,
Say I have the following Backbone Router: class App.Routers.ThingsRouter extends Backbone.Router initialize: -> new
So basically what I want to do is have my routes.php setup so that

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.