问题描述
我使用 .append()
从另一个 PHP 页面加载页面中的动态数据.问题是来自另一个页面的内容有 jquery 滚动条和工具提示.如果我在该页面中包含 jquery.js 和剩余的 javascript 代码,则动态加载的内容可以很好地与 jquery 滚动条和工具提示配合使用,但是如果我删除该页面中的 jquery,它将被原始 Windows 滚动条和工具提示替换.对此的解决方案是什么?
I use .append()
to load dynamic data in a page from another PHP page. The problem is the content from the another page have jquery scrollbars and tooltips. If I include jquery.js and remaining javascript code in that page the dynamically loaded content works well with the jquery scrollbars and tooltips but if I remove the jquery in that page it gets replaced with original windows scrollbar and tooltips. What is the solutions= for this?
示例滚动条代码,
$('div.box').scrollbars();//滚动条
PS:我需要从第二页删除脚本文件的原因是在使用 .load() 或 .append() 时,主机页面冻结,直到动态数据完全加载.
PS: The reason I need to remove the script files from the second page is while using .load() or .append(), the host page freezes till the dynamic data loads completely.
推荐答案
在外部文件中再次添加脚本文件确实是一个糟糕的做法.相反,您必须在回调中添加 $('div.box').scrollbars();//滚动条
.
It will be really a bad practice too add script files again in the external file. Instead you have to add $('div.box').scrollbars();// scrolbars
in the callback.
示例:
$("#samplediv").load('external_page.extension', function()
{
$("#samplediv").scrollbars();
});
这篇关于工具提示,JQuery 滚动条在 Ajax 加载的内容中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!