Yes, I'm still using prototype :)
I have a list of thumbnails in a container, and a Sortable created for the container so I can reorder them.
I also want to add a separate droppable outside the container div to accept imgs I want to trash.
I can't figure out how to get the thumb to drop onto the trash outside of the thumb container. With the code below, the image won't drop until it's release over the original "thumbs" div.
Anyone have any pointers?
HTML (erb):
<div id="thumbs">
<% @thumbs.each do |thumb| %>
<img class="crop_img" id="thumb_<%=thumb.id%>" src="<%=thumb.filename%>" /> <% end %>
</div>
<div id="crop_trash" style="display: block; width:100px;height:100px;background-color:#CCCCCC">
Trash
</div>
<script type="text/javascript" >
//<![CDATA[
Sortable.new_create('thumbs',
{
format:/_(\d*)$/,
onUpdate: function(){
new Ajax.Request('/the/url',
{asynchronous: true,
evalScripts: true});
},
only: 'crop_img',
constraint: false,
containment: ['thumbs','crop_trash'],
tag: 'img'
});
Droppables.add('crop_trash',
{
accept: 'crop_img',
onDrop: function(drag){
thumb_handler.delete_thumb(drag.id.substring(drag.id.lastIndexOf('_')+1));
}
}
);
//]]
</script>