I have problem here with a button. So I want to clone items from one list to another one. I also want to add a button when passed to the other list. The problem appears when I click the button. Nothing happens. Item does not get removed. Do you have any idea why that's happening?
jQuery:
$( function() {
$( "#sortable1").sortable({
connectWith: ".connectedSortable",
items: "li:not(.ui-state-disabled)",
remove: function(event, ui) {
ui.item.clone().append( "<button class='cancelBut'>Cancel</button>" ).appendTo('#sortable13');
$(this).sortable('cancel');
}
}).disableSelection();
$( "#sortable13").sortable({
connectWith: ".connectedSortable",
items: "li:not(.ui-state-disabled)"
}).disableSelection();
$( ".cancelBut" ).click(function() {
//$(this).parent().remove();
alert("It works");
});
});
HTML:
<div id="items" style="display: none">
<ul id="sortable1" class="connectedSortable">
<li class="ui-state-default ui-state-disabled">Items</li>
<li class="ui-state-default"><p>Item 1</p></li>
</ul>
</div>
<ul id="sortable13" class="connectedSortable">
<li class="ui-state-default ui-state-disabled">Drag Here</li>
</ul>
Im new to jQuery so sorry if the answer is obvious and thanks for help :)