jquery - load scripts and css with ajax loaded contents -


i have page contains menu sidebar links , div load ajax content other pages in it, content load scripts , css not work, use html 5 history load load content other pages.

$(function () {      $('.menuanchor').click(function (e) {         href = $(this).attr("href");         loadcontent(href);         // history.pushstate         history.pushstate('', 'new url: ' + href, href);         e.preventdefault();     });      // event makes sure back/forward buttons work     window.onpopstate = function (event) {         console.log("pathname: " + location.pathname);         loadcontent(location.pathname);     }; });  function loadcontent(url) {     // uses jquery load content     $.get(url, {}, function (data) {         $(".contn_btm_mid_bg").html($(data).find('.contn_btm_mid_bg').html());         //$.validator.unobtrusive.parse(".contn_btm_mid_bg");     });      // these 2 lines make sure nav bar reflects current url     $('li').removeclass('current');     $('a[href="' + url + '"]').parent().addclass('current'); } 

ok 1 thing load css , js externally using code

$("<link/>", {    rel: "stylesheet",    type: "text/css",    href: "/styles/yourcss.css" }).appendto("head"); 

same js


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -