In my backbone.js, when I call model.save() the url gets the current URL path prefixed in it.
Suppose my model is:
RegisterModel = Backbone.Model.extend({
defaults: {
id: ''
},
url: 'register/confirm'
});
My router is defined like:
AppRouter = Backbone.Router.extend({
routes: {
'signup/confirm/:key': 'confirm'
},
confirm: function(key) {
var mod1 = new RegisterModel({key:key});
mod1.save();
}
});
Now if I understand the ajax request should be sent to
register/confirm
Instead it is sent to…
signup/confirm/register/confirm
What could be leading to this? Could this be because of pushstate:true that I am using to start Backbone.History???
Backbone.history.start({pushState:true});
I need this because I don’t want to use hashed URLs.
Can you use URLs that are relative to the site’s root? In that case you could try: