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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:51:13+00:00 2026-05-28T13:51:13+00:00

Does in Backbone.Router exists the events both before and after performing routing? My app

  • 0

Does in Backbone.Router exists the events both before and after performing routing?
My app works with jQuery.mobile and call to $.mobile.changePage was needed before route was performed and in controller have access to currently showing page by $.activePage. When action of controller is done, I should trigger the create event on document to get ‘enhanced’ by $.mobile newly created elements.
I did this by replacing loadUrl

Backbone.history.loadUrl = ( function( old  ){
    return function() {  
       Router.trigger("all:before");   
       old.apply( Backbone.history, arguments );
       Router.trigger("all:after" );
    }
})( Backbone.history.loadUrl  );



 //Router.initialize
 initialize: function() {
     this.bind( "all:before", function( ) {  
         $.mobile.changePage( window.location.hash.split( "/" )[0] || "home", { changeHash:false} );
     });

     this.bind( "all:after", function() {
       $.mobile.activePage.trigger('create'); 
     });  
  }

Is there maybe some built-in events like this?

  • 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-28T13:51:14+00:00Added an answer on May 28, 2026 at 1:51 pm

    there is no before and after event in the Backbone.Router as of now.

    version 0.5.3 supports the following router events (all events here)

    “route:[name]” (router) — when one of a router’s routes has matched.

    not sure for which release it will be, but a general route event is being developed,
    in the github trunk commit #419 has this functionality, but it’s not released in a new version yet

    there are allready reported issues (idea’s) for a before event, check the github issue on that here.

    so, the before event is not yet in there, the after event will come some time later,
    if you really already need an after event, there is a way you can put it in yourself,
    by binding to the ‘all’ event instead, it catches all events including all ‘route:routename’ events. then just split the event name and if it starts with route you have the general route event. (this can of course be removed and changed if the after event is released in one of backbone’s releases)

        this.bind('all', function (trigger, args) {
                   var routeData = trigger.split(":");
                    if (routeData[0] === "route") {
                       // do whatever here.  
                       // routeData[1] will have the route name
                    }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What does a Backbone.js 'Model' expect back from the server after a call to
Backbone.js provides a navigate(fragment, [options]) method for its Backbone.router objects, which does the following
Does anyone know which event is fired after a view is rendered in backbone.js?
What advantages does forge.ajax has over plain old jQuery.ajax or backbone.save() calls? I understand
This is a very similar question to Backbone not binding events to jQuery Popover
I have a router that does the site navigation nicely and also works when
after I change to Backbone-Relational my model stopped to work when I call destroy()..
I'm using jquery mobile and backbone.js to create a single page mobile application. The
I have following piece of code from my Backbone project: App.Controllers.Test = Backbone.Router.extend({ routes:
Can anyone please explain me what delegateEvents in backbone.js does? The documentation did not

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.