On Sat, Jan 22, 2011 at 1:15 PM, Daniel Donaldson <[email protected] > wrote:
> i'm trying to change the width of the dragged item on stop, which > seems like it should be easy, but when i add a function on the stop > event things get all screwy. > > i've got it on jsfiddle: http://jsfiddle.net/d8nieldonaldson/smYeh/ > You're using the draggable stop event which fires on mouseup, well before the cloned item gets animated and comes to stop in its new home in the sortable. There are three events of interest on the sortable in this case: * receive <http://docs.jquery.com/UI/Sortable#event-receive> * update <http://docs.jquery.com/UI/Sortable#event-update> * stop <http://docs.jquery.com/UI/Sortable#event-stop> So using the stop event is most fitting (and latest) and worked for me $( "#target" ).sortable({ revert: true, stop: function(event, ui) { ui.item.find("img").width(140); } }); and then you'd remove your draggable stop event handler for two reasons 1. it triggers too soon to be useful in this case 2. by referencing $(this) in the draggble stop you were modifying the original draggable element (which sticks around) rather than the cloned element. This may explain why things were getting "all screwy". That and you need to modify the img width, not the li width. - Richard -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
