问题
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