用法:
containment
默認:
false
定義可排序項在拖動時被約束的邊界框。
注意:為包含指定的元素必須具有計算的寬度和高度(盡管不需要明確)。例如,如果您有 float: left
可排序子項並指定 containment: "parent"
,請確保在可排序/父容器上也有 float: left
,否則它將具有 height: 0
,導致未定義的行為。
- Element: 用作容器的元素。
- Selector: 一個選擇器,指定要用作容器的元素。
-
String:標識要用作容器的元素的字符串。可能的值:
"parent"
,"document"
,"window"
.
代碼示例:
使用指定的 containment
選項初始化可排序:
$( ".selector" ).sortable({
containment: "parent"
});
初始化後獲取或設置containment
選項:
// Getter
var containment = $( ".selector" ).sortable( "option", "containment" );
// Setter
$( ".selector" ).sortable( "option", "containment", "parent" );
相關用法
- JQuery UI Sortable connectWith用法及代碼示例
- JQuery UI Sortable cancel用法及代碼示例
- JQuery UI Sortable cursorAt用法及代碼示例
- JQuery UI Sortable change( event, ui )用法及代碼示例
- JQuery UI Sortable classes用法及代碼示例
- JQuery UI Sortable cursor用法及代碼示例
- JQuery UI Sortable create( event, ui )用法及代碼示例
- JQuery UI Sortable scrollSpeed用法及代碼示例
- JQuery UI Sortable option用法及代碼示例
- JQuery UI Sortable update( event, ui )用法及代碼示例
- JQuery UI Sortable widget用法及代碼示例
- JQuery UI Sortable instance用法及代碼示例
- JQuery UI Sortable handle用法及代碼示例
- JQuery UI Sortable tolerance用法及代碼示例
- JQuery UI Sortable axis用法及代碼示例
- JQuery UI Sortable stop( event, ui )用法及代碼示例
- JQuery UI Sortable opacity用法及代碼示例
- JQuery UI Sortable out( event, ui )用法及代碼示例
- JQuery UI Sortable forcePlaceholderSize用法及代碼示例
- JQuery UI Sortable refresh用法及代碼示例
- JQuery UI Sortable disable用法及代碼示例
- JQuery UI Sortable scroll用法及代碼示例
- JQuery UI Sortable distance用法及代碼示例
- JQuery UI Sortable sort( event, ui )用法及代碼示例
- JQuery UI Sortable scrollSensitivity用法及代碼示例
注:本文由純淨天空篩選整理自jqueryui.com大神的英文原創作品 Sortable containment。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。