Created
August 1, 2011 14:00
-
-
Save nathanpalmer/1118173 to your computer and use it in GitHub Desktop.
This file contains 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
var ItemCollection = Spine.Model.setup("Item", [ "itemToAdd", "allItems", "selectedItems" ]); | |
ItemCollection.extend(DataBind); | |
ItemCollection.include({ | |
addItem: function() { | |
if (this.itemToAdd != "") { | |
this.allItems.push(this.itemToAdd); | |
this.itemToAdd = ""; | |
this.save(); | |
} | |
}, | |
removeSelected: function() { | |
var allItems = this.allItems; | |
this.selectedItems.forEach(function(item) { | |
var index = allItems.indexOf(item); | |
if (index >= 0) { | |
allItems.splice(index,1); | |
} | |
}); | |
this.selectedItems = []; | |
this.save(); | |
}, | |
sort: function() { | |
this.allItems.sort(); | |
this.save(); | |
} | |
}); | |
var Item = ItemCollection.create({ itemToAdd: "", allItems: [ "Fries", "Eggs Benedict", "Ham" ], selectedItems: [] }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment