AJAX加载后绑定自定义事件处理程序 [英] Bind custom event handler after ajax load
本文介绍了AJAX加载后绑定自定义事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
具体我期待绑定收藏夹到一个特定的元素。一般情况下我只是这样做: $('a.lightbox')灯箱();
,但运行不正常的,因为我正在做一些加载使用AJAX。看着jQuery的API,我发现 .bind()
和 .live()
,但我没有得到任何事情时,我做的 $('a.lightbox)。绑定('收藏夹')
.load()调用。
Specifically I'm looking to bind lightbox to a specific element. Normally I would just do this: $('a.lightbox').lightBox();
but that isn't working since I'm doing some loading with AJAX. Looking at the jQuery API I found .bind()
and .live()
but I'm not getting anything when I do $('a.lightbox').bind('lightBox')
after the AJAX .load()
call.
我在想什么?
推荐答案
您需要添加一个回调函数处理的。
You need to add a callback function that handles that.
$("#div").load(url, {}, function(){ $('a.lightbox').lightBox(); });
绑定是不会帮你,因为该事件没有得到它的事件触发。
Bind isn't going to help you, as the event isn't getting an event fired on it.
这篇关于AJAX加载后绑定自定义事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文