I have a website that loads once and then each time a user clicks a button instead of loading a new page, the content is just replaced via ajax. However on one of the pages I'm using jquery-ui and for example, if I land in "index.html" and then click to go to that page the script is not loading but if I go directly to that page the script does load correctly. I've tried to condition the loading of the script by doing.
var hash = window.location.hash.substr(1);
var a = window.location.href.lastIndexOf("dev.html");
var b = window.location.href.lastIndexOf(".html");
var l = window.location.href.substring(a,b);
$(document).bind('ready',function(){
if((hash == "dev") || ((l == "dev") && (hash != dev)) || (l == hash)){
//$('#tabs').html("<script type=\"text\/javascript\" src=\"assets\/js\/tabs-ui-init.js\"\/><\/script>");
$.ajax({
type: "GET",
url: "assets/js/tabs-ui-init.js",
dataType: "script"
});
}
});
But the script won't load anyway...what am I doing wrong? I've tried to load it via $.getScript() and some other ways like instead of .bind using .live and binding to load and unload but no success...the way this site is loaded is like explained in here :http://nettuts.com/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/
Edit @Jim Davis: I think this is just what I need, just why isn't it running ?? I made the reference for the Content as the scripts it'll load and the Panel is a div where to place those scripts still the code isn't running on page load =/