繁体   English   中英

jquery selectable 完成后的调用函数

[英]call function after jquery selectable is done

在 jquery selectable 完成正在执行的操作(排序或其他)之后,我无法找到一种调用函数的方法。 我需要找出什么时候完成移动东西,因为它接缝我无法访问某些元素。 这是代码:

我想调用这个函数来修复 zIndex 数字.. reparaZindex() 我试图把它放在开始或更新中,但没有任何作用。

$(function() {
    $( ".sortable" ).disableSelection();
    $( ".sortable" ).sortable({
        start: function(event, ui) {},
        update: function (event, ui) {}
       });
  });

我的脚本工作正常,加载页面时我可以检查所有 id-s,但更改列表后不起作用。 这是一个链接,可以查看:

(我已经在上面的例子中停止了 reparaZindex,但它不起作用)

试试这段代码:

$(function() {
    $( ".sortable" ).disableSelection();
    $( ".sortable" ).sortable({
        stop : function(event, ui){
        reparaZindex(); 
        alert("bananas eat children");
   }
       });
  });

如果您收到警报但您的功能不起作用,则意味着您的 reparaZindex() 做错了。


$(function() 
{

    $( ".sortable" ).disableSelection();
    $( ".sortable" ).sortable({ 

        start: function(event, ui) {
        var start_pos = ui.item.index();
        ui.item.data('start_pos', start_pos);
    },





        update: function (event, ui) {
        var start_pos = ui.item.data('start_pos');
        var end_pos = ui.item.index();

            var eroare=0;

            //incepe trimiterea la bd a indexurilor

            for(var i=0;i<ui.item.parent().children().length;i++){
                    if(1==0) //eroare
                    eroare=1;
                    var x =ui.item.parent().children()[i];
                     //$(x).find('img').css('z-index',500-i);
                     y=$(x).children()[0];
                     y.style.zIndex=500-i*2;
                     if($(x).children().length>1){
                    c=$(x).children()[1];
                    TEMP=500-i*2+1;
                    c.style.zIndex=TEMP;
                    //alert(TEMP);
                    //alert($(x).children()[1].id)
                    }
                }
            if(eroare==0)//daca bd a upatat indexurile pt start_pos la eng pos
            {
                var copii=ui.item.parent().children();
                for(var i=0;i<ui.item.parent().children().length;i++){
                    //alert(ui.item.parent().children().eq(i).id())
                }


            }
            else {


                }   


    },
    stop: function(event, ui) { $.each($(".sortable > li"), function() {alert("!!!"+$(this).attr("id"));}); }

  });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM