我有一个简单的自定义Tab键模块,加载标签与AJAX请求(通过 $(ELEM).load()
)。在那个装有AJAX每一页我有一些JavaScript。第一次加载页面(通过URL,而不是AJAX的直接输入),JavaScript的火灾达完美。当我通过AJAX的标签导航离开该页面,从页面的JavaScript不加载了。
I have a simple custom tabbing module, that loads tabs with an AJAX request (via $(elem).load()
). On each page that is loaded with AJAX I have some JavaScript. The first time the page loads (via direct input of URL, not AJAX), the javascript fires up perfectly. When I navigate away from the page via the AJAX tabs, the javascripts from the pages aren't loading anymore.
有没有什么办法可以强制他们执行?
Is there any way I can force them to execute?
(即不点火被放置在一个 $(文件)。准备中的JavaScript()
功能是否有帮助)
(The javascript that is not firing is placed in a $(document).ready()
function if that helps)
您需要使用 负载的回调()
功能:
You need to use callback of load()
function:
$(elem).load('source.html', function() {
// here you need to perofrm something what you need
ActionOnDocumentReady();
});
您可以把你的 $(文件)。就绪
所有行动统一到一些功能(如 ActionOnDocumentReady()
),并把它在 负载()
回调。
You can put all your actions in $(document).ready
into some function (ex ActionOnDocumentReady()
) and call it on load()
callback.