Changing the name of a div tag, which has been dragged and dropped with a helper:"clone" on it?

StackOverflow https://stackoverflow.com/questions/22853997

سؤال

I hope this makes sense but here goes... I have a div which is draggable and has a helper on it, now what I need to do is change the name of the id when it is dropped on the stage, at the moment it gets the ui-draggable ui-draggable-dragging class and I can't seem to add an id to it. Thanks in advance

هل كانت مفيدة؟

المحلول

You could use the stop function of draggable.

JS:

$( ".draggable" ).draggable({
    stop: function() {
       $(this).attr('id','dragged');
    }
 });

HTML

<div id="dragme" class="draggable">
    test
</div>

Here is a Fiddle: http://jsfiddle.net/d1m5n/H5Utr/

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top