The sortable demos haven't worked for a while. ( http://
dev.rubyonrails.org/ticket/4690 )
The documentation is, in most cases, out of date. The following
worked for me:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script type="text/javascript" src="js/min/prototype.js"></script>
<script type="text/javascript" src="js/min/scriptaculous.js?
load=effects,dragdrop"></script>
<script type="text/javascript">
//<![CDATA[
function buildList(times) {
var ul = document.createElement("ul");
ul.id = "ul" + times;
var li = null;
for (var i = 0; i < 5; ++i) {
li = document.createElement("li");
li.id = "li" + times + "_" + i;
li.appendChild(document.createTextNode("List " + times + " Item " +
i));
ul.appendChild(li);
}
document.body.appendChild(ul);
Sortable.create(ul, {});
if ((--times) > 0) {setTimeout("buildList(" + times + ")", 2000)}
}
window.onload = function() {
setTimeout("buildList(3)", 2000);
}
//]]>
</script>
<style type="text/css">
body {
position:relative;
color: black;
background-color: white;
font-size: small;
}
li {margin: 2px; padding: 2px .5em; list-style-type:none;border:1px
solid;cursor:move;}
#ul1 li {background-color: #dbb;}
#ul2 li {background-color: #bdb;}
#ul3 li {background-color: #bbd;}
</style>
</head>
<body>
</body>
</html>
TAG
On May 19, 2006, at 7:45 AM, Sam Rowe wrote:
I'm writing an appliation that contains several dynamically created
lists. I
had hoped that the following method for using the Sortable library
from
scriptaculous would work:
1) create the list
2) create a Sortable for it
3) create another list
4) create a Sortable for it
and so on. Unfortunately this doesn't work. I can't find any info
in the
documentation for Sortable.create[1] about this behavior. However,
one of the
demo pages[2] (which doesn't work in FF on Linux btw) mentions the
following:
The script tag that encloses the Sortable.create function
calls needs to occur after all of the lists that you
intend to use. IE.. in this example if you were place the
"Sortable.create("firstlist"...);" call immediately after that list
(and before the second list) you would only be able to drag from
list 1 to list 2 and not from list 2 to list 1.
If it helps, I'm not interested in dragging from one list to
another. Just in re-ordering each list as its own entity.
Is there any way to not have to destroy all Sortables and then
re-create them every time an element is added to a list or a new list
comes into being?
Any help appreciated!
Also, FYI [3] doesn't work in FF on Linux either.
References:
[1] http://wiki.script.aculo.us/scriptaculous/show/Sortable.create
[2] http://wiki.script.aculo.us/scriptaculous/show/SortableListsDemo
[3] http://wiki.script.aculo.us/scriptaculous/show/GhostlySortableDemo
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs