mcm*_*iii 21 jquery jquery-ui jquery-ui-sortable
绝对常见的可排序案例:
<script>
$(function() {
$("#sortable").sortable();
});
</script>
<ul id="sortable">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
问题.需要在某些条件下取消拖动项目并且Andrew Whitaker有一个很好的建议 ,但这种方法仅适用于jquery-ui-draggable并且无法进行排序:
$("#sortable").sortable({
start: function() {
return false; // will still cause `this.helper is null`
}
});
Run Code Online (Sandbox Code Playgroud)
对建议会很有帮助.
roo*_*oot 28
Sortable具有使用调用的"取消"功能sortable('cancel')
.
从文档:"取消当前可排序的更改并将其还原到当前排序开始之前的状态." 请参见http://api.jqueryui.com/sortable/#method-cancel.
用法示例:
$("#sortable").sortable({
stop: function(e, ui) {
if ("I need to cancel this") {
$(ui.sender).sortable('cancel');
}
}
});
Run Code Online (Sandbox Code Playgroud)
Ben*_*ank 25
返回false
作为fudgey表明伟大的让事情动态不可排序的作品,但也有一个cancel
选项的排序配置,它可以让你设置静态unsortables还有:
$("#sortable").sortable({
// this prevents all buttons, form fields, and elemens
// with the "unsortable" class from being dragged
cancel: ":input, button, .unsortable"
});
Run Code Online (Sandbox Code Playgroud)
Mot*_*tie 15
该sort
回调函数确实为排序为拖动(拖动同一演示):
$("#sortable").sortable({
sort: function() {
if ($(this).hasClass("cancel")) {
$(this).sortable("cancel");
}
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
40708 次 |
最近记录: |