The jQuery Sortable()
is working well, and if I try to destroy and create the sortable, also working well.
but if try to $(document).unbind('mousemove')
and recreate sortable, it only works once and then never work.
I know I can change the code; but I want to know why.
Here is the code below, also on jsfiddle (http://jsfiddle.net/webjjin/YJEf5/)
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<div id="container">
<ul id="sortable">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
</ul>
</div>
<button id="btn">Destroy and create</button>
<button id="unbind">Unbind</button>
<script>$("#sortable").sortable();</script>
<script>
var html = $('#container').html();
$('#btn').click(function(){
$("#sortable").sortable('destroy');
$('#container').empty();
setTimeout(function(){
$('#container').append(html);
$("#sortable").sortable();
}, 500);
});
$('#unbind').click(function(){
jQuery(document).unbind('mousemove').unbind('mouseup');
})
</script>