0
私は3はそれがすべてのリンクファイルの属性を置き換える必要がありJqueryの.load()関数が正常に起動しないのはなぜですか?
- のonloadステップ行うと仮定jqueryの関数を作った
- それは$に(「#内容を」)のサブページをロードする必要がありますクリック
- 再び、それはすべてのリンクに代わる機能をrefireする必要があり、再び
次のコードは、私はそれもロードされたページのリンクを交換するべきだと思い、再びすべてのURLを置き換える必要があり2つの段階が、doesntの火災第三段階まで動作しますか?
$(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', '#');
}
});
}
はどのようにあなたが知っています正常に動作する必要があります 'redoIt()'と呼ば取得されていませんか?あなたはそれにブレークポイントを入れましたか?または最初に 'console.log()'ステートメント?エラーコンソールにJavaScriptエラーがありますか? 'LoadPage()'が呼び出されていますか? – jfriend00
リンクを選択するあなたの方法は本当に恐ろしいです....長い間、jQueryのこのような恐ろしい誤用を見たことはありません。 – ThiefMaster
redoIt()にアラート(this.href)を追加しましたが、返信はありませんでした – danny