Skip to content

Instantly share code, notes, and snippets.

@roman-manchenko
Last active August 29, 2015 14:18
Show Gist options
  • Save roman-manchenko/a1da2b93e82995873ea2 to your computer and use it in GitHub Desktop.
Save roman-manchenko/a1da2b93e82995873ea2 to your computer and use it in GitHub Desktop.
add: function (answer) {
if (answer.has('order')) {
return this;
}
var maxOrderModel = this.max(function (model) {
return model.get('order');
});
if (_.isEmpty(maxOrderModel)) {
answer.set('order', 0);
} else {
answer.set('order', maxOrderModel.get('order') + 1);
}
BB.Collection.prototype.add.apply(this, arguments);
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment