Dynamically changing the jQuery sortable placeholder value
How do I use an if statement in the jQuery sortable plugin to dynamically determine the placeholder class?
If the item 开发者_如何学Cis being dragged around in#listA
then I want the placeholder class to be .ImInListA
If the item is being dragged around in #listB
then I want the placeholder class to be .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>
Thanks!
I do it like this:
$("#listA li").live('mouseover', function(){
$( "#listA" ).sortable( "option", "placeholder", 'ImInListA' );
});
$("#listB li").live('mouseover', function(){
$( "#listB" ).sortable( "option", "placeholder", 'ImInListB' );
});
Hope this help someone :)
精彩评论