开发者

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

开发者 https://www.devze.com 2023-03-11 11:48 出处:网络
I\'m using jcrop for jquery to crop images. To use it, I\'m using $(function(){ $(\'#jcrop\').Jcrop(); });.

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

精彩评论

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