开发者

Question about jQuery and Bind

开发者 https://www.devze.com 2023-04-01 22:29 出处:网络
I am trying to combine bind and dragable $(\".qq-upload-success\").draggable({//functions}); have some one a solution?

I am trying to combine bind and dragable

$(".qq-upload-success").draggable({//functions});

have some one a solution?

I load th开发者_开发问答is class with ajax. So this function doesn't work, so I have to bind() or live() this action to this class.

$(".qq-upload-success").bind("draggable", function()    {
        $.draggable({
        helper:'clone',
        start: function(event, ui) {
            var txta = $("textarea#kapiteltext");
            $("div#pseudodroppable").css({
                position:"absolute",
                top:txta.position().top,
                left:txta.position().left,
                width:txta.width(),
                height:txta.height()
            }).droppable(options).show();
        },
        stop: function(event, ui) {
            $("div#pseudodroppable").droppable('destroy').hide();
        }
        });
    });  

or

$(".qq-upload-success").bind("drag", draggable({
        helper:'clone',
        start: function(event, ui) {
            var txta = $("textarea#kapiteltext");
            $("div#pseudodroppable").css({
                position:"absolute",
                top:txta.position().top,
                left:txta.position().left,
                width:txta.width(),
                height:txta.height()
            }).droppable(options).show();
        },
        stop: function(event, ui) {
            $("div#pseudodroppable").droppable('destroy').hide();
        }
    }));

thank you!


It is not possible to add non-event things (e.g. draggable) for all elements created in the future.

You need to create it when the element exists, e.g. by using $('.foo:not(.ui-draggable)').draggable(...) whenever such an element gets added.

0

精彩评论

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