$("#test-list").sortable({
handle : '.handle',
update : function () {
var order = $('#test-list').sortable('serialize');
}
});
怎样能让鼠标就在#test-list容器里面实现拖动?现在情况是元素可以拖拽到#test-list外面,哪位大侠用过那位大侠用过jquery-ui-1.7.1.custom.min.js控件的,请给我点指导。跪谢了
------解决方案--------------------
官方文档讲的很清楚: http://jqueryui.com/demos/sortable/
containment Element, String, Selector Default:false
Constrains dragging to within the bounds of the specified element - can be a DOM element, 'parent', 'document', 'window', or a jQuery selector.
Note: the element specified for containment must have a calculated width and height (though it need not be explicit), so for example, if you have float:left sortable children and specify containment:'parent' be sure to have float:left on the sortable/parent container as well or it will have height: 0, causing undefined behavior.
Code examples
Initialize a sortable with the containment option specified.
$( ".selector" ).sortable({ containment: 'parent' });
Get or set the containment option, after init.
//getter
var containment = $( ".selector" ).sortable( "option", "containment" );
//setter
$( ".selector" ).sortable( "option", "containment", 'parent' );