|
Hello, I am new to Scriptaculous, and was recently brought into a
project using it to create an email Newsletter builder. The idea is that
the user will have lists of elements that he can add to the email page by
dragging the element he wants to add from an “available sections”
container, to a “loaded sections” container. Dragging from
the loaded to available will “remove” the element from the
email. Draggables and Droppables weren’t working out so well;
dragging from loaded to available wouldn’t remove the element from
loaded, it would revert even though revert:false. So I started using
Sortables. After a little bit of hacking, I got them working—using
the onChange function I set a global variable with the id of the dragged
element, and using the onUpdate function I’d iterate through the drop
zone and see if the dragged element was dropped inside that zone. If it
was dropped inside that zone, I parse the ID of the draggable and get the
draggable’s corresponding div (XHTML fragment), setting it’s
display to block. Here’s my code: Sortable.create("availableSectionsDiv",
{
tag:'div',
dropOnEmpty:true,
containment:sections,
only:'templateSelectItem',
onChange:function(drg){g_draggedElement = drg.id;},
onUpdate:function(drp) {
var bDroppedHere = false;
//console.log(drp.hasChildNodes());
for(var i=0;i<drp.childNodes.length;i++) if(drp.childNodes[i].id ==
g_draggedElement) bDroppedHere = true;
if(bDroppedHere) {
var
strZMFileName=g_draggedElement.substring("selectZone_".length,g_draggedElement.length);
$(strZMFileName).style.display = "none";
}
} }); Sortable.create("loadedSectionsDiv",
{
tag:'div',
dropOnEmpty:true,
containment:sections,
only:'templateSelectItem',
onChange:function(drg){g_draggedElement = drg.id;},
onUpdate:function(drp) {
var bDroppedHere = false;
for(var i=0;i<drp.childNodes.length;i++) if(drp.childNodes[i].id ==
g_draggedElement) bDroppedHere = true;
if(bDroppedHere) {
var
strZMFileName=g_draggedElement.substring("selectZone_".length,g_draggedElement.length);
$(strZMFileName).style.display = "block";
}
} }); Works great in FireFox, but in IE it doesn’t resort
either of the lists. The elements will pile up wherever I drop
them. Is the code I’m using to hide and show the draggable’s
corresponding XHTML fragment somehow preventing it from resorting? Is
there a function I should call at the end of these to do the resort?
Should I be using something else altogether?? Thanks in advance, Mike _____________________________________________________________ |
_______________________________________________ Rails-spinoffs mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
