English 中文(简体)
j 区分多种相同的选择
原标题:jQuery distinguishing multiple identical selector instances

I have a selector like this:

$list = $( ul.sortable );

页: 1 UI 具有可分类的 p。

网页上有多种可分类的清单。 因此,每一次选择都是在实际显示只有1次的情况下选择的,而其他选择则随着分类的崩溃而崩溃。

当晚在拖拉之后发生连火时,我就获得了第一场火的顺序,尽管最后一场大火是这样。

How can I, when I actually process the sort later in a function, pick out the particular ul that is :not(.collapsed)? Currently it looks like this:

$order = $item_list.nestedSortable( toHierarchy );

Edit:

Here is what we have on page load:

$item_list      = $( ul.sortable );
$url            =  admin/navigation/order ; // CI Controller to process stuff
$cookie     =  open_links ;
$data_callback  = function(event, ui) {
  // Grab the group id so we can update the right links
  return {  group  : ui.item.parents( section.box ).attr( rel ) };
}

// Do sort
sort_tree($item_list, $url, $cookie, $data_callback);

最终,上述尼伯为获得命令和将贾克斯带给控制员。

如果我改变上述选择,那么所有ul子都不会被适用,并且可以分类。 因此,我估计,如果能够用某种方式将这种区别与“树木功能”区分开来,我可以正确操作。

在这里,我与以下各方合作:

sort_tree = function($item_list, $url, $cookie, data_callback, post_sort_callback)
{
    // collapse all ordered lists but the top level
    $item_list.find( ul ).children().hide();

    // this gets ran again after drop
    var refresh_tree = function() {

        // add the minus icon to all parent items that now have visible children
        $item_list.parent().find( ul li:has(li:visible) ).removeClass().addClass( minus );

        // add the plus icon to all parent items with hidden children
        $item_list.parent().find( ul li:has(li:hidden) ).removeClass().addClass( plus );

        // remove the class if the child was removed
        $item_list.parent().find( ul li:not(:has(ul)) ).removeClass();

        // call the post sort callback
        post_sort_callback && post_sort_callback();
    }
    refresh_tree();

    // set the icons properly on parents restored from cookie
    $($.cookie($cookie)).has( ul ).toggleClass( minus plus );

    // show the parents that were open on last visit
    $($.cookie($cookie)).children( ul ).children().show();

    // show/hide the children when clicking on an <li>
    $item_list.find( li ).live( click , function()
    {
        $(this).children( ul ).children().slideToggle( fast );

        $(this).has( ul ).toggleClass( minus plus );

        var items = [];

        // get all of the open parents
        $item_list.find( li.minus:visible ).each(function(){ items.push( #  + this.id) });

        // save open parents in the cookie
        $.cookie($cookie, items.join( ,  ), { expires: 1 });

         return false;
    });

    $item_list.nestedSortable({
        disableNesting:  no-nest ,
        forcePlaceholderSize: true,
        handle:  div ,
        helper:  clone ,
        items:  li ,
        opacity: .4,
        placeholder:  placeholder ,
        tabSize: 25,
        listType:  ul ,
        tolerance:  pointer ,
        toleranceElement:  > div ,
        stop: function(event, ui) {

            post = {};
            // create the array using the toHierarchy method
            post.order = $item_list.nestedSortable( toHierarchy );

            // pass to third-party devs and let them return data to send along
            if (data_callback) {
                post.data = data_callback(event, ui);
            }

            // refresh the tree icons - needs a timeout to allow nestedSort
            // to remove unused elements before we check for their existence
            setTimeout(refresh_tree, 5);

            $.post(SITE_URL + $url, post );
        }
    });
最佳回答

Sorry, your question is kinda hard to understand, so I ll have to guess a little.

You have several ul s on a page, and you made them all sortable and made sure only one is visible. At a later point in time, you d like to request the sort order of the visible UL. I guess the first attempt to get the visible UL would be this:

$( ul.sortable:visible )

From which you can request the sort order. But if you process the sort, you probably know one of the li s that is a child of the ul. So you could also go for

$(li).closest( ul.sortable );

在其中,利文是划一的要素之一,这也应当使你成为根基。 不知道如果你重新使用拖网和干道,是否可行。 也许,可以分类的东西本身提供了三种方法(这种方法可能是什么)。

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签