From 96dd53ce4d1346b33ac42ada7b49c16487f3438b Mon Sep 17 00:00:00 2001 From: Matt Moriarity Date: Sat, 28 Jul 2007 23:56:14 -0400 Subject: [PATCH] Fixed a bug where scrolling didn't work if all the songs were removed Fixed by recreating the Sortable when a song is dropped. --- public/javascripts/application.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/public/javascripts/application.js b/public/javascripts/application.js index b4087fd..62beeaa 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -94,24 +94,30 @@ Event.addBehavior({ // Make the songs in a show sortable and // allow songs from the sidebar to be dropped in '#songs_list': function() { + sortableOptions = { + constraint: false, + handle: 'draggable', + onUpdate: function(element) { + new Ajax.Request('/shows/' + $P('show_id') + ';reorder', { + method: 'put', + parameters: Sortable.serialize(element) + }); + } + }; + Lyrix.Droppable.attach(this, { accept: 'song', onDrop: function(element) { new Ajax.Request('/usages?show_id=' + $P('show_id'), { - parameters: 'id=' + encodeURIComponent(element.id.gsub('song_', '')) + parameters: 'id=' + encodeURIComponent(element.id.gsub('song_', '')), + onComplete: function() { + Sortable.create('songs_list', sortableOptions); + } }); } }); - Lyrix.Sortable.attach(this, { - handle: 'draggable', - onUpdate: function(element) { - new Ajax.Request('/shows/' + $P('show_id') + ';reorder', { - method: 'put', - parameters: Sortable.serialize(element) - }) - } - }); + Lyrix.Sortable.attach(this, sortableOptions); }, // Allow songs from a show to be dropped out of the show -- 2.11.4.GIT