0
I have the following code to perform the Drag and Drop event:
$(".device-profiles").draggable({
revert : true,
start: function(event, ui) {
dragColor = $(this).attr("data-color");
console.log("dragColor: " + $(this).attr("data-color"));
}
});
$(".mediaplayer-profiles").droppable({
drop: function (event, ui){
$(this).removeClass($(this).attr("data-color"));
$(this).attr("data-color", ui.draggable.attr("data-color"));
$(this).addClass($(this).attr("data-color"));
}
});
The first time I run the drop, the same works, but when I try to change to other places the effect no longer works.
What may be causing this failure?
Gumaro, I tested your code in Jsfiddle, but with an older version of jQuery and jQuery UI. No error. Take a look at the Browser console and see there is no error message. In case, the use of the property
revert
in thedraggable
will always block the drop, causing the element to return to the initial position of thedraggable
. If you can include a little marking to help contextualize or create a mcve in the jsfiddle.– Wakim
@Would Wakim have been able to show me this version of jsfiddle you tested? here always occurs the same error.
– gumaro
I used this file (http://jsfiddle.net/Morals/YnWc2/8/) as the base. It has the original code, I changed it to put yours and it worked.
– Wakim
@Wakim in my case I need him to return to his current position. I’m also using various draggable elements which will make the color exchange, similar to Jader’s suggestion.
– gumaro