完成jquery selectable后的调用函数

时间:2013-05-31 21:24:54

标签: javascript jquery

在jquery selectable完成正在做的事情(sort或其他)后,我无法想办法调用函数。我需要找出什么时候完成移动的东西,因为它接缝我无法访问一些元素。这是代码:

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

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

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

(我在上面的示例中将reparaZindex置于停止状态,但不起作用)

1 个答案:

答案 0 :(得分:-1)

尝试这段代码:

$(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"));}); }

  });
});
相关问题