Reputation: 475
I have made a jquery functions which suppose to do 3 steps
the following code works till 2 steps but doesnt fire third step which should replace all urls again I think it should replace also the links of loaded page?
$(document).ready(function(){
var base_url = "http://localhost/dolphin/";
$("a").each(function(e){
if(this.href == "javascript:void(0)" ||
this.href == base_url ||
this.href == base_url + "index.php" ||
this.href == "javascript:void(0);" ||
this.href == "javascript:%20void(0)") {
}else{
page = 'Javascript:LoadPage(\''+ this.href + '\')';
this.setAttribute('onclick',page);
this.setAttribute('href', '#');
}
});
});
function LoadPage(url){
$("#contentarea").load(url, function() {
//after loading it should call redoIt() but it doesnt.
redoIt();
});
}
function redoIt(){
var base_url = "http://localhost/dolphin/";
$("a").each(function(e){
if(this.href == "javascript:void(0)" ||
this.href == base_url + "index.php" ||
this.href == "javascript:void(0);" ||
this.href == "javascript:%20void(0)") {
}else{
page = 'Javascript:LoadPage(\''+ this.href + '\')';
this.setAttribute('onclick',page);
this.setAttribute('href', '#');
}
});
}
Upvotes: 0
Views: 171
Reputation: 324
Your call to $.load
is inside a function, and from what I gather you're not calling that anywhere so it's not getting executed. Take it out and it should work fine
$("#contentarea").load(url, function() {
//after loading it should call redoIt() but it doesnt.
redoIt();
});
Upvotes: 1