Set up the draggables 'on load', no need for a script element per draggable.

This commit is contained in:
Paul van Tilburg 2010-09-12 12:38:15 +02:00
parent 0fe45a24ee
commit ff5481df13
2 changed files with 6 additions and 2 deletions

View File

@ -129,7 +129,7 @@ module Plemp::Views
"init_plemp();"
end
end
body do
body(:onLoad => "return setup_draggables();") do
self << yield
end
end
@ -202,8 +202,8 @@ module Plemp::Views
em "#{d.file}: Unsupported file type!"
end
end
script(:type => "text/javascript") { "setup_draggable('#{d.file}')" }
end
end
end
end

View File

@ -5,6 +5,10 @@ function init_plemp(base_url) {
}
// Creates a Draggable for each div with the given ID.
function setup_draggables() {
$$('.draggable').each(function(d) { setup_draggable(d.id); });
}
function setup_draggable(id) {
drag = new Draggable(id, { scroll: window });
old_endeffect = drag.options.endeffect;