From d7a57c76f6f327f4a5520a437b2d17a02bc58a99 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Fri, 9 Mar 2012 23:15:16 +0100 Subject: Changed ordering to use a comparator function. --- static/playlist.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'static/playlist.js') diff --git a/static/playlist.js b/static/playlist.js index b94de61..373098c 100644 --- a/static/playlist.js +++ b/static/playlist.js @@ -2,7 +2,10 @@ $(function(){ PlaylistItem = Backbone.Model.extend({}); Playlist = Backbone.Collection.extend({ model: PlaylistItem, - localStorage: new Store("playlist") + localStorage: new Store("playlist"), + comparator: function(item) { + return item.attributes.order_id; + } }); window.items = new Playlist; PlaylistItemView = Backbone.View.extend({ @@ -25,7 +28,6 @@ $(function(){ } }); PlaylistView = Backbone.View.extend({ - current_id: 1, el: $('#playlist'), initialize: function() { items.bind('add', this.addOne, this); @@ -35,9 +37,7 @@ $(function(){ items.fetch(); }, add: function(item) { - item.track_id = item.id; - item.id = this.current_id; - this.current_id++; + item.order_id = items.length+1; var model = items.create(item); if(items.indexOf(model) < 2) { sound_hint(model); -- cgit v1.2.3