AshesOfOwls / jquery.shapeshift

A dynamic grid system with drag and drop functionality.
http://ashesofowls.github.com/jquery.shapeshift/
MIT License
1.67k stars 311 forks source link

Get the draggued and dropped element after drop complete #85

Open ghaliano opened 10 years ago

ghaliano commented 10 years ago

Hi,

in my case i need to send an ajax request to switch dragged element rank in the database so i need the dragged and dropped element after drop complete

my js code look like this:

$('.grid').shapeshift({
                handle: '.move'
            }).on("ss-drop-complete", function (e) {
                console.log(e);
            });

but I don’t found any useful attribute to get this two informations

Thanks

ninteh commented 10 years ago

From documentation:

 $containers.on "ss-rearranged", (e, selected) ->
    console.log "This container:", $(this)
    console.log "Has rearranged this item:", $(selected)
    console.log "Into this position:", $(selected).index()
$(selected) 

is before position

$(selected).index()

is new position. you can store these into variables and use AJAX to send to PHP database for positioning. Then load your ordering from the database on the PHP page load

jakenoble commented 10 years ago

I am trying to do this, but I want to detect the target element, even if it is outside of the main container - is that possible?