开发者

Jquery Live and Draggable

开发者 https://www.devze.com 2022-12-18 23:10 出处:网络
I am binding a click event to an image using Jquery Live binding.  The first time I click on the image the simplemodal popup launches and draggable works fine.  After that, the simplemodal popup sti

I am binding a click event to an image using Jquery Live binding.  The first time I click on the image the simplemodal popup launches and draggable works fine.  After that, the simplemodal popup still launches and the draggable item will not drag.  Any ideas?

Code of Live Click Event:

$("table tr td img:not(.Help)").live("click", function(){

    $("#draggable").draggable({
        containment: 'parent',
        drag: function(e, ui){
            alert("dragging");
        }
    });

    $("#modal").modal({
        onShow: function(){
            $("html").css("overflow", "hidden");
        },
        on开发者_JAVA技巧Close: function(){
            $("html").css("overflow", "auto");
            $("table tr td img").live("click", function(){});
            $.modal.close();
        }
    });
});


In case anyone looks for this in the future the solution was to put the "draggable" code in the onShow callback.

$("table tr td img:not(.Help)").live("click", function(){ 

    $("#modal").modal({ 
        onShow: function(){
             $("#draggable").draggable({ 
                containment: 'parent', 
                drag: function(e, ui){ 
                    alert("dragging"); 
                } 
            });  
            $("html").css("overflow", "hidden"); 
        }, 
        onClose: function(){ 
            $("html").css("overflow", "auto"); 
            $("table tr td img").live("click", function(){}); 
            $.modal.close(); 
        } 
    }); 
}); 
0

精彩评论

暂无评论...
验证码 换一张
取 消