我正在研究一个无限滚动,如下所示:
<script type="text/javascript">
$(function () {
var page = 1;
var $ol = $('#namesList');
var $waypoint = $('#namesWaypoint');
var opts = { offset: '100%' };
$waypoint.waypoint(function () {
console.log('waypoint triggered');
$waypoint.waypoint('remove');
$.get('/Home/AjaxPage?page=' + page++, function (data) {
data.names.forEach(function (name) {
$ol.append($('<li class="span3" style="margin-bottom: 0 !important;">').text(name));
});
$waypoint.waypoint(opts);
});
}, { offset: '100%' });
});
</script>
看到这一行:
$ol.append($('<li class="span3" style="margin-bottom: 0 !important;">').text(THEFOLLOWINGCODEBLOCK));
我需要在此处附加以下内容:
<li class="span3" style="margin-bottom: 0 !important;">
<div class="thumbnail">
<div>
<a href="/Haberler/@item.Id/@Html.URLFriendly((string)@item.Title)">
<img src="@item.MainImage.Path?width=260&height=150" alt=""></a><br />
<strong class="other_news"><a href="/Haberler/@item.Id/@Html.URLFriendly((string)@item.Title)">@Html.Truncate((string)item.Title, 30)</a></strong>
<br />
<span class="detail_content">@Html.Truncate((string)item.PreviewText, 75)</span>
<br />
<span class="detail_content">@item.DatePublished.ToString("dd/MM/yyyy")</span>
</div>
</div>
</li>
有更清洁的方法吗?
我应该使用 jquery tmpl 吗?我不想引入很多脚本...