我正在構建幾個加載了ajax的級別,而當前級別菜單位於右側並且需要將其放在內容區域中。我不確定如何在ajax加載的內容中加載一個點擊事件,在它自己的內容div中加載另一個級別。德代碼我工作是在這裏:如何在ajax加載的內容中加載帶有鏈接的另一個頁面
var $level = $('#navigation a'),// Links on the right
last = null;// Last Level
$level.click(function(){
if(last != this){ // let's avoid needless requests
var url = 'html/' + this.hash.slice(1) + '.html';
$('#content').html('<p class="loading">Loading...</p>').load(url, function(){
this.scrollLeft = 0;//scroll back to the left
});
}
last = this;
this.blur(); // Remove the awful outline
return false;
});
$level.eq(0).click(); // Load the first Level
的最終目標是讓用戶能夠挖掘的內容區域內的圖像(即的Ajax加載)到該級別內瀏覽,或加載另一個級別(.html頁面)。我試圖避免是必須在腳本中聲明每個級別的每個實例一樣會有超過5
我的測試環境是在這裏:http://www.beingproperties.com/test/jscroll-ajax/
任何幫助,將不勝感激。謝謝! -Chris
爲了使事件(例如$('#mydiv')。live('click',function(e){your codes}); –
那麼上面的代碼如何被重寫。我已閱讀這裏的信息(http://beski.wordpress.com/2010/11/01/jquery-ajax-link-inside-ajax-loaded-content-problem/),但我不清楚如何編寫我不必定義每個頁面加載。 – Centinel3