PDA

View Full Version : Drag an Item From a Sortable onto a Droppable to Delete it? (Scriptaculous)


Mikeboy
01-16-2008, 10:42 PM
Hi

I have set up two sortable lists, and can drag elements between the two, updating the order field in my database.

However, rather than moving elements into a second sortable list, I simply need to delete them.

So I think I need to use Droppables.add, and drag elements from the sortable list onto it. However, I am having problems.


Sortable List - (simplified)
<ol id="firstlist" style="cursor: move">
<li id="item_'.$id.'">blah blah</li>
<li id="item_'.$id.'">blah blah</li>
</ol>


<script type="text/javascript">
function updateOrder()
{
var options = {
method: "post",
parameters: { data: Sortable.serialize("firstlist")}
};

new Ajax.Request("sortorder_test_call.php", options);
}

Sortable.create("firstlist",
{ dropOnEmpty:false,handle:'handle',containment:["firstlist","wastebin"],constraint:false,onUpdate:updateOrder});


So I made a div area called Wastebin


<div id="wastebin">
i.e. Drag item here to delete
</div>


function nutscrape()
(
var options = {
method: "post",
parameters:'id=' + encodeURIComponent(element.id)
};

new Ajax.Request("delete.php", options);
}

Droppables.add("wastebin",
{containment:["firstlist","wastebin"], accept: 'firstlist', onDrop: nutscrape});


I know the last JavaScript function etc is very wrong. I am new to this.

Please can someone give some pointers as to how this is supposed to be set up?

Thanks very much in advance.
Mike

A1ien51
01-22-2008, 12:16 AM
You figure this out? Been awhile...

Eric