The easiest way to achieve this is to override the Backbone url method on the coupon model with the one you define. For example, you can:
Affiliates.Coupon = Backbone.Model.extend({ urlRoot : "server/somecontroller/", url : function(){ var url = this.urlRoot + this.id; if(this.get("type")){ url = url + "/?type=" + this.get("type"); } return url; } });
This solution is easy to implement, but has a drawback: the generated URL will be used for every action that is synchronized with the server (fetch, save, ..).
If you need finer control over the creation of the URL, depending on what action you perform, you will need to override Backbone Sync for your model.
Beorn
source share