Arm*_*and 9 jquery jquery-ui-sortable
我正在使用jQuery UI链接多个列表,并允许在不同列表之间拖放项目.
在这种情况receive下,我想获取项目被放入的列表.这ui.item.parent()是正确的方法,还是有一个属性ui或event让我直接访问它?
<ul><li>item 1</li></ul>
<ul><li>item 2</li></ul>
Run Code Online (Sandbox Code Playgroud)
$('ul').sortable({
connectWith: 'ul',
receive: function(event, ui) {
var targetList = ui.item.parent();
}
});
Run Code Online (Sandbox Code Playgroud)
不,新父母没有直接的财产(因为.parent()很容易),所以你拥有的是正确的. 您可以在ui此处查看所有属性.
如果你想要.closest(),第二个父母等等......最好让UI保持苗条,因为它们都很容易遍历; 这也节省了直接在ui对象上提供引用的费用.
由于receive事件是在接收列表上调用的,因此您可以获取新的父项$(this).源列表可通过以下方式访问ui.sender.
$('ul').sortable({
connectWith: 'ul',
receive: function(event, ui) {
var sourceList = ui.sender;
var targetList = $(this);
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13256 次 |
| 最近记录: |