我正在使用jpoint的航點插件。它適用於頁面上的div。但是當我使用AJAX添加新的div時,它不適用於那些新添加的div。它不算他們。如何讓jQuery waypoint插件計算新增內容?
這裏是我的代碼:
Waypoint = $('.Picture-1A').waypoint(function(direction){
if(direction == 'down'){
id = $(this.element).children(".PictureID").text();
$.post('ajax/count-pictures-views.php', {picture_id: id}, function(data){
Waypoint.refreshAll();
});
}
});
我也用在(),但它並沒有爲所有的工作,默認和新增。 我如何才能使它適用於新添加的內容?
這是我的Ajax頁面:
$(document).ready(function(){
endPictures = true;
scrollCount = 0;
$(window).scroll(function(){
if(endPictures == true){
if(scrollCount == 0){
if($(window).scrollTop() >= $(document).height() - $(window).height() - 3000){
scrollCount = 1;
picturesCount = $(".Picture-1A").length;
$.post('ajax/load-latest.php', {off_set:picturesCount}, function(data){
if(data){
$("#loadMore").append(data);
scrollCount = 0;
}else{
$("#loadMore").append("<div class=\"NoMorePictures\"><center>There are no pictures left.</center></div><br/ >")
endPictures = false;
scrollCount = 0;
}
});
}
}
}
});});
你能顯示完整的詳細信息代碼如何添加內容? – user5200704
@ user5200704我已經添加了Ajax腳本。我認爲問題出在'$ .waypoints('refresh')'上。我認爲使用它可以解決問題,但我不知道應該把它放在腳本中。 – FarrisFahad
使用$ .waypoints('refresh')後添加新內容時,您可以添加ajax函數。 – user5200704