下面我有 3 个链接作为选项卡:
<li data-tab-id="self" class="tab selected"><a href="activity">Near You</a><span class="unread-count hidden" style="display: none;"></span></li>
<li data-tab-id="friends" class="tab"><a href="#">Following</a><span class="unread-count hidden" style="display: none;"></span></li>
<li data-tab-id="user" class="tab"><a href="#">Your Activity</a><span class="unread-count hidden" style="display: none;"></span></li>
当我点击上面的链接 Jquery 点击功能被触发
$(".hd-ui-activity li a").click(function(e) {
e.preventDefault();
var tabid = $(this).parent().attr('data-tab-id');
if(tabid == "self"){
getFunc1(totalRecords);
} else if(tabid == "friends") {
getFunc2(totalFriendsRecords);
} else if(tabid == "user") {
getFunc3(totalUserRecords);
}
});
当单击每个链接/选项卡时,getFunc1()
会调用例如将 html 附加到以下 div 的函数(每个 func 都有自己的 div)
<li data-section-id="following" data-component-bound="true">
<ul class="module-list">
<!-- USER ACTIVITY JSON -->
</ul>
<a class="ybtn ybtn-primary ybtn-large more-wishlist" href="#" onclick="javascript:getRecentActivityFriends(event)">
<span data-component-bound="true" class="loading-msg following">See more recent activity</span>
</a>
</li>
div 上只显示 4 个列表结果,当用户单击see more activity
按钮时,更多结果被加载到 div 中。现在的问题是当页面加载时它正确显示 4 个结果,但是当我再次单击链接而不是按钮时,所有数据都会显示出来。我很难在选项卡之间导航。我怎样才能避免这种情况?
更新:
var totalFriendsRecords = '<?=$this->followingTotal?>';
function getRecentActivityFriends(event)
{
if (event != null){
disabledEventPreventDefault(event);
}
getFriendsActivity(totalFriendsRecords);
}
主页.js
var totalFriendsRecordsView = 0;
function getFriendsActivity(totalFriendsRecords)
{
var activityHtml = ''
$.ajax({
url:baseUrl + "activity/feedfollowing",
data:{'total':totalFriendsRecordsView},
dataType:"json",
type:"POST",
success:function(data){
for(var i=0; i<data.length; i++){
activityHtml = '<p>'+data[i][name]+'</p>';
}
$('#activity-feed li[data-section-id=following] .module-list').append(activityHtml);
if( totalFriendsRecords <= totalFriendsRecordsView){
$('.following').text('Nothing beyond here ...');
$('.following').removeAttr('onclick');
$('.following').removeAttr('href');
}
}
});
}