Unexpected change events when save with {wait:true} #1478
Closed
Description
I think it should be no different with or without wait:true, but
Backbone.sync = function(method, model, options) {
var data = model.toJSON()
setTimeout(function() {
options.success(_.extend({ 'id': 1, 'b': 2, 'c': true }, data), {})
}, 10)
};
var A = Backbone.Model.extend({})
, a = new A()
a.fetch({
success: function() {
a.on('change', function(model, evt) { console.log(_.keys(evt.changes)) })
a.on('change:id', function(model, data) { console.log('change:id: ' + data) })
}
})
setTimeout(function() {
console.log('no wait')
a.save({ 'b': 6 })
}, 100)
setTimeout(function() {
console.log('wait: true')
a.save({ 'b': 8 }, { wait: true })
}, 200)
and the result
no wait
changed: ["b"]
wait: true
change:id: 1 // this is unexpected
changed: ["b"]
Do I use it in wrong way, or a bug?