1
我有以下代碼爲jquery移動頁面。當我直接運行它時,它可以工作,但是當我從不同的頁面鏈接到它時,它不會加載。我試過在推薦鏈接中關閉數據ajax,但這沒有什麼區別。有任何想法嗎?動態內容不加載與jquery移動
這裏是代碼:
var urlQuery = location.search;
urlQuery = urlQuery.replace('?', '');
var split = urlQuery.split('=');
var id = split[1];
$(document).delegate('[data-role="page"]', 'pageinit', function(){
$.get('../ws/bars.php?id=' + id, function(data) {
$('[data-role="content"]').html(data);
$('[data-href="specials"]').trigger('click');
});
});
$(document).delegate('[data-role="navbar"] a', 'click', function(event){
$('.content_div').hide(); // hide all the .content_div's
$('#' + $(this).attr('data-href')).show(); // display the div that's been clicked $('a.pageTab').removeAttr('style'); // remove styling from the buttons
$(this).attr('style','color: #eee;'); // add styling to the active button
});
無論答案我從這個搞定了,請給我的,爲什麼還有什麼讓我能明白是怎麼回事。
謝謝!
這工作我已經得到了上面的代碼,但我希望的是,回答我的問題會在我的其他網頁工作。但是,當我點擊一個鏈接並轉到第二頁時,這不起作用 - 第二頁上的動態內容不會加載。此外,我只在這個頁面上有這些ID的元素。我的應用程序中的每個頁面都不同,並且它們都在單獨的HTML文件中。我已經將第二頁的代碼添加到我的問題中,以便您可以看到那裏發生了什麼(以原始格式,在我嘗試document.delegate之前) – 2012-03-21 21:08:14