I am trying to build a team picker application that allows you drag the players who are not into teams into teams.
I am using JQUERY UI sortable with “connectWith”. So far I can drag the players from the players list into separate teams, however I want to be able to fire an update for each individual player when they are moved between teams.
I have created a jsfiddle:
When the “player” is dragged from the players list to the team list the script alerts the name of the two lists however what I would like to be able to get is the id of the line item that has been moved so that I can send an update similar to:
myupdatescript.php?Player=[li item id]&FirstList=Players&SecondList=Team1
Is there anyway of extracting the id of the line item that is getting moved?
Try this as your update function:
Note that you’ll get the alert twice because you have two instances of “.connectedSortable”, one for Team1 and the other for Team2. So Team1’s sortupdate event will trigger, then Team2’s sortupdate event will trigger.
Updated jsfiddle: http://jsfiddle.net/pjFgw/1/
jQuery UI referrence: http://jqueryui.com/demos/sortable/#event-update