开发者

How to use Jcrop() for jquery on DOM generated at the future?

I'm using jcrop for jquery to crop images. To use it, I'm using $(function(){ $('#jcrop').Jcrop(); });.

My problem is that, the target element #jcrop is generated using ajax. So when I use the above code, it doesn't recognized the DOM element.

How do I change the code to mak开发者_如何学编程e it work with .live()??


Delegate is an alternative to the .live() method and is the recommended way to go. Delegate your event to run when dynamic #jcrop element is loaded:

$("body").delegate("#jcrop", "load", function(){
    $(this).Jcrop();
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜