且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jquery sortable保持在容器边界内

更新时间:2022-10-14 19:16:05

You need to pass the containment option:

$(function() {      
    $( ".sortable" ).sortable({
       axis: 'y',
       containment: "parent" 
    }).disableSelection();
});​

Here is a working example with the code: http://jsfiddle.net/VzpBq/

Definition of the containment option from the Sortable jQueryUI API:

Defines a bounding box that the sortable items are contrained to while dragging.