如何在jQuery可排序插件中使用if语句来动态确定占位符类?
如果在#listA
中拖动项目,那么我希望占位符类为.ImInListA
如果在#listB
中拖动项目,那么我希望占位符类为.ImInListB
jQuery的
$( "#listA, #listB" ).sortable({
connectWith: ".connected_sortable",
placeholder:
//if the current item is being dragged in #listA
//use css class selector .ImInListA
//else
//use css class selector .ImInListB
}).disableSelection();
HTML:
<ul id="listA" class="connected_sortable">
<li value="1">list_a_1</li>
</ul>
<ul id="listB" class="connected_sortable">
<li value="2">list_b_2</li>
</ul>
谢谢!
答案 0 :(得分:1)
我这样做:
$("#listA li").live('mouseover', function(){
$( "#listA" ).sortable( "option", "placeholder", 'ImInListA' );
});
$("#listB li").live('mouseover', function(){
$( "#listB" ).sortable( "option", "placeholder", 'ImInListB' );
});
希望这有助于某人:)