I'm curious with contrary intuitive behavior of Model.sync function.
The second argument for sync is the model, and when it is Backbone.sync it does make sense. But when it behaves as a proxy:
var MyModel = Backbone.Model.extend({baseUrl})
var myModel = new MyModel({id})
console.log(myModel.url()) // will issue baseUrl + id path
myModel.sync(data, myModel)
It is bit of a superfluous to pass same model on which you called sync.
In case you will not pass it the very unfriendly error will pop up:
backbone.js:1907 Uncaught Error: A "url" property or function must be specified
And this is done on design. As when you have close look at docs they clearly state the second parameter to be obligatory.
I'm trying to understand what is the reasoning behind not making it bit flexible, and pass this model through on the library level vs making it on your own?
PS: I've not able to find definite answer, but will gladly close this ticket if any will be found.
Aucun commentaire:
Enregistrer un commentaire