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

  • Home
  • SEARCH
  • 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 8809315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:50:36+00:00 2026-06-14T02:50:36+00:00

I tried to use backbone with a pushstate: $(document).ready(function(){ var App = Backbone.Router.extend({ routes:

  • 0

I tried to use backbone with a pushstate:

$(document).ready(function(){
    var App = Backbone.Router.extend({
        routes: {
            "/":            "homepage",
            "/questions":   "questions"
        },
        homepage: function() {
            console.log('why');
        },
        questions: function() {
            console.log('this is not working?');
        }
    });
    var the_app = new App();
    $("a").click(function(ev) {
        the_app.navigate( $(this).attr("href"), true);
        return false;
    });
    Backbone.history.start({pushState: true});
})

The problem is that whenever I click a link like one of this:

<a href="/"> home </a>
<a href="/questions"> questions</a>
<a href="/justlink"> just link</a>

Location in the browser changes without reloading, but the function, associated with it and which I already defined in routes, does not executes.
Any idea what have I done wrong?

  • 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-14T02:50:38+00:00Added an answer on June 14, 2026 at 2:50 am

    From the fine manual:

    extend Backbone.Router.extend(properties, [classProperties])

    […] Note that you’ll want to avoid using a leading slash in your route definitions:

    You want your routes to look like this:

    routes: {
        "":            "homepage",
        "questions":   "questions"
    }
    

    Demo: http://jsfiddle.net/ambiguous/ybPcg/

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

Sidebar

Related Questions

I tried to use the following function in order to set the div's position
Im tried to use NAudio demo app for MP3 Streaming in Csharp, when i
I tried to use object expression to extend the IDelegateEvent, but in fsi there
I tried to use Backbone.js for one of my projects, but got a problem
Is there a clean way to somehow use underscore.js _.extend function (or any other)
I use localStorage to persist the data of my Backbone app. But every time
I tried use js to change my url from http://localhost/text/index.php#mainpage%20menu1 to http://localhost/text/index.php#homepage%20menu1 My code
$(input[name='add'].my).click(function(){ //i tried use this <input type=button name=add value=..../> //element to find his parent's
I used function imagecopyresampled to cropping image. I tried use file_put_contents and fwrite to
im trying to use templates for my backbone views. I tried it with underscore.template

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.