Yii:如何将代码附加到列表视图的分页事件?
我有一些附加到列表视图中的项目的 jQuery 单击/悬停事件,但是当用户单击下一页并且通过 ajax 加载结果时,事件不再有效。
我可以将 live 用于某些事件,但由于它对于悬停事件已贬值且效率低下,我正在寻找一种方法将我的事件在加载新项目时附加到它们...这可能吗?
I have a few jQuery click/hover events that attach to items in a list view, but when a user clicks to the next page and the results are loaded through ajax the events are no longer valid.
I can use live for some events, but since it is depreciated and inefficient for hover events I'm looking for a way to attach my events to new items when they are loaded... Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找 afterAjaxUpdate。
http://www.yiiframework.com/doc/api/1.1/CListView #afterAjaxUpdate-详细信息
You are looking for afterAjaxUpdate.
http://www.yiiframework.com/doc/api/1.1/CListView#afterAjaxUpdate-detail
您应该能够在 $.ajax 方法上指定回调:
如果您有任何正在使用的代码示例,它可能会帮助您充实一个不错的答案 - 不太确定这是否是您想要的寻找与否。
You should be able to specify a callback on your $.ajax method:
If you have any code examples of what you're working with, it would probably help flesh out a decent answer for you - not quite sure if this is what you were looking for or not.