Skip to content
This repository was archived by the owner on Aug 25, 2018. It is now read-only.

Commit d668478

Browse files
committed
pre-defined id support for collection additions
1 parent 7465643 commit d668478

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backbonefire.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@
439439
*/
440440
create: function(model, options) {
441441
// XXX model prototype broken: this.model.prototype.idAttribute worked around as this.idAttribute
442-
model[this.idAttribute] = Backbone.Firebase._getKey(this.firebase.push());
442+
model[this.idAttribute] = model[this.idAttribute] || Backbone.Firebase._getKey(this.firebase.push());
443443
options = _.extend({ autoSync: false }, options);
444444
return Backbone.Collection.prototype.create.call(this, model, options);
445445
},
@@ -450,7 +450,7 @@
450450
*/
451451
add: function(model, options) {
452452
// XXX model prototype broken: this.model.prototype.idAttribute worked around as this.idAttribute
453-
model[this.idAttribute] = Backbone.Firebase._getKey(this.firebase.push());
453+
model[this.idAttribute] = model[this.idAttribute] || Backbone.Firebase._getKey(this.firebase.push());
454454
options = _.extend({ autoSync: false }, options);
455455
return Backbone.Collection.prototype.add.call(this, model, options);
456456
},

0 commit comments

Comments
 (0)