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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:19:54+00:00 2026-05-26T20:19:54+00:00

I have some navigation links on the dom when the app is started which

  • 0

I have some navigation links on the dom when the app is started which I wish to hijack for progressive enhancement via Backbone (theres a very static text content version underlying the backbone app).

The html looks like this:

...
<body>
<header>
<nav>
<ol>
<li>
<a href="/en/home">home</a>
</li>
<li>
... few more links
</header>

Then my App is instantiated using:

var App = (function(fw){
 var $      = fw;
 var workspace            = {};
 var self     = {};
 var lang     = "en";
 var models     = {...};
 var views     = {...};
 var collections   = {...};
 self.init = function() {
  workspace = new Workspace(
  {
    routes: {
     "/": "home",
     "/home": "home",
     "/terms": "terms",
     "/news": "blog"
   },
    lang : lang
  })
 }
 return self;
});
var app;
// launch
$(document).ready(function() {
 app = new App(jQuery);
 app.init();
});

The workspace is just a router and those routes from the app are correctly processed into the router via the initialize function, also the links work and change the URL as expected and do it with hashes on older browsers. The problem is that no callbacks are ever made within the Router/Workspace itself. It’s simply mute and doesnt fire the functions when the clicks are made

Here’s my Workspace/Router:

var Workspace = Backbone.Router.extend({

 routes : {},
 //functions                     <------------THESE
 home:    function(e){
  e.preventDefault();
  console.log("home here");
  App.views.HomeView.render();
 },
 terms:    function(){          //<-----------NEVER
  console.log("terms here");
  App.views.TermsView.render();
 },
 blog:    function(){           //<-----------FIRE
  console.log("blog here");
 },
 initialize:  function(params){
  var t = this;
  var tmpr = {};
  for(var i in params.routes)
  {
    //this just fuses lang and each route so /home becomes /en/home 
                  tmpr["/"+params.lang+i] = params.routes[i];
  }
  this.routes = tmpr; // this is fine and when logged it shows nicely with all routes looking good
  // router will only ever initialize once so lets deal with the stuff currently on the DOM before the app is inited.
  $("a",$("header")).click(function(e){
   e.preventDefault();
   Backbone.history.navigate($(this).attr("href"),true);//<-- true is set? should fire methods?
   // I've also tried all kinds of variations like t.navigate(..) where t is this workspace
  });
//this also seems to be fine and either does hashes or states
  if(history && history.pushState) {
   Backbone.history.start({
    pushState : true
   });
   console.log("has pushstate");
  } else {
   Backbone.history.start();
   console.log("no pushstate");
  }
  console.log("Router inited with routes:",this.routes);//logs routes nicely
 }
});
  • 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-26T20:19:54+00:00Added an answer on May 26, 2026 at 8:19 pm

    The routes have already been bound when the initialize function is run (see the backbone source).

    You can trigger the routes binding with the _bindRoutes function:

    this.routes = tmpr;
    this._bindRoutes();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm have some issues adding a class to 2 navigation links on a theme.
I have a separate navigation php which has a list of links and menu
I have a helper method that creates navigation links for some controllers. def gen_associations(controllers)
A friend of mine wants to have some navigation-based mc links in frame 1,
In my layout.html.twig I have a navigation bar with some links. I want the
I have created some rounded navigation tabs using CSS and am having trouble when
I have no idea why, but for some reason the top navigation at http://www.wilwaldon.com/crossing/badnav.html
I have some ASP.NET web services which all share a common helper class they
I have some C# / asp.net code I inherited which has a textbox which
I have some code like this in a winforms app I was writing to

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.