Last active
August 29, 2015 14:18
-
-
Save roman-manchenko/a1da2b93e82995873ea2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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