2
votes

I have the following routes:

var Workspace = Backbone.Router.extend({

  routes: {
    "": "index"
  },

  index: function() {
    ...
  }       
});

At now I can trigger this route like this Backbone.history.navigate('', true); and all works fine. But now I need to add GET params to that router to be possible trigger and handle route like this:

var Workspace = Backbone.Router.extend({

  routes: {
    "?:query": "index"
  },

  index: function(query) {
    ...
  }       
});

But unfortunately my index callback don't get executed when I trigger Backbone.history.navigate('?needShowPopup=true', true);

How should I define and trigger route to pass and handle GET parameters for my index route?

1

1 Answers

0
votes

I would do that

var Workspace = Backbone.Router.extend({

  routes: {
    "*": "index"
  },

  index: function() {
    var query = location.search;
    // work with query
  }       
});

Let me know if you get a problem.