Tooltip, JQuery scrollbars not working in Ajax loaded content

陌路散爱 提交于 2019-12-11 11:33:54

问题


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?

Sample scrollbar code,

$('div.box').scrollbars();// scrolbars

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.


回答1:


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.

Example:

$("#samplediv").load('external_page.extension', function()  
{  
   $("#samplediv").scrollbars();  
});


来源:https://stackoverflow.com/questions/16273099/tooltip-jquery-scrollbars-not-working-in-ajax-loaded-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!