This is my code for a draggable connected to a sortable. The thing is, I am creating an LI with a bunch of attributes. BUT when I drag an item to the droppable div, the sortable creates a new li tag and wraps my created li with it.
It looks something like this:
<ul>
<li class="ui-draggable" style="display: list-item;">
<li class="X" onclick="myFunc()"> My LI</li>
<li>
</ul>
While my intention is to have something like this:
<ul>
<li class="X" onclick="myFunc()"> My LI</li>
</ul>
So how do i do this?
And the code:
$(document).ready(function() {
$('.draggable_text > li').draggable({
helper: function(event, ui) {
return '<div class="placeholder_sortable"> </div>'
},
connectToSortable:'#stagerows'
});
$('#stagerows').sortable({
handle: '.drag_handle',
placeholder: 'placeholder_sortable'
});
/**
* When item is dropped from the Add <Stuff>
*/
$('#stagerows').droppable({
drop: function(event, ui){
return ui.draggable.html('<li class="X" onclick="myFunc()"> My LI</li>')
}
});
});