您好,登錄后才能下訂單哦!
1、視圖(index)
1 <!--start--> 2 <div data-am-widget="list_news" class="am-list-news am-list-news-default"> 3 <!--列表標題--> 4 <div class="am-list-news-bd"> 5 <ul class="am-list" id="NewsList"> 6 @{ Html.RenderPartial("PartialNews", Model);} 7 </ul> 8 </div> 9 </div>10 <button type="button" class="am-btn am-btn-primary am-btn-block" pageindex="1" onclick="LoadData(this,'/News/Index?Id=@ViewBag.Id', 'NewsList')">加載更多</button>11 <button class="am-btn am-btn-default" ><i class="am-icon-spinner am-icon-spin"></i>加載中</button>12 <!--end-->
2、對應的部分視圖(PartialNews)
1 @foreach (var item in Model) 2 { 3 <li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left"> 4 <div class="am-u-sm-4 am-list-thumb"> 5 6 <a href="/Mobile/News/Detail/@item.ID" class=""> 7 <img src="@(item.Image??"/Images/defaultnew.png")" alt="@item.Title" /> 8 </a> 9 </div>10 <div class=" am-u-sm-8 am-list-main">11 <h4 class="am-list-item-hd">12 <a href="/Mobile/News/Detail/@item.ID" class="text_block">@item.Title</a>13 </h4>14 <div class="am-list-item-text">@item.CreateDate</div>15 <div class="am-list-item-text">@item.MinDes.RemoveHTMLTags()</div>16 </div>17 </li>18 }
3、js函數
1 <script> 2 function LoadData(o, u, p) { 3 $(o).hide().next().show(); 4 var pageindex = parseInt($(o).attr("pageindex")); 5 pageindex++; 6 $(o).attr("pageindex", pageindex); 7 if (u.indexOf('?') < 0) { 8 u = u + "?from=data" 9 }10 $.get(u + "&pageindex=" + pageindex, function (data) {11 if (data == "") {12 $(o).attr("pageindex", parseInt($(o).attr("pageindex")) - 1)13 $(o).show().next().hide()14 $(o).html("沒有更多了!");15 $(o).removeAttr("onclick");16 } else {17 $(data).appendTo($("#" + p));18 $(o).show().next().hide()19 }20 });21 }22 </script>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。