I think you statically define the urlRoot and url properties before you start the init pageModel pages (not quite sure where you get m and n from, though ...)
Both url and urlRoot can be a function, so you can pass parameters during instance creation and dynamically set them on the model.
A simple example defining a collection and then creating one
var ContactDetailCollection = Backbone.Collection.extend({ model: ContactDetail, url: function(){ return URL_CONTACTS1 + this.options.detail_userid + "/" + this.options.detail_contactid; } }); var myContactDetails = new ContactDetailCollection({ detail_userid: foo, detail_contactid: bar });
As I said, I'm not sure what your init function does, I assume that this is something non-standard from your application that I need not worry about.
I am sure that the main thing to remove is to set a dynamic url and urlRoot
joevallender
source share