Ajax加载选项卡后的回调 [英] Callback after ajax loading a tab

查看:100
本文介绍了Ajax加载选项卡后的回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将一些代码应用于ajax加载的选项卡的内容? 我尝试在加载的内容中使用$(document).ready,但这阻止了CSS样式的加载(不知道为什么).

How can I apply some code to the content of an ajax loaded tab? I tried using $(document).ready inside the loaded content, but that prevented css styles from loading (don't know why).

有回调函数吗?我是否应该以其他方式在已加载的文档中使用$(document).ready和样式?

Is there a callback function? Should I use $(document).ready and styles inside the loaded document in some other way?

如果在加载的文档中使用$(document).ready很好,我还应该在其中包含对jquery及其插件的引用吗?

If using $(document).ready inside the loaded document is fine, should I also include references to jquery and its plugins in it?

推荐答案

您是否尝试过 load活动?这应该被调用,当选项卡的内容已被加载.

Have you tried the load event? This should be called, when the contents of the tab have been loaded.

通常,您不应将已加载的元素视为新页面,而应调用$(document).ready.这不是一个新页面,而是向DOM中添加了一些新元素.所有ajax方法均具有在成功加载数据后调用的回调方法.

In general you shouldn't treat the loaded element as a new page and call the $(document).ready. This is not a new page, but some new elements added to the DOM. All ajax methods feature a callback method that is invoked, when the data are successfully loaded.

这篇关于Ajax加载选项卡后的回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆