手机版上拉刷新dropload结合arttemplate实现

站长手记 作者: 2024-09-03 06:45:01
手机版上拉刷新dropload结合arttemplate实现

话不多说,直接上代码

{js:artTemplate}
<link href="{theme:javascript/dropload/dropload.css}" rel="stylesheet" />
<script type="text/javascript" src="{theme:javascript/dropload/dropload.min.js}"></script>

<div class="newly_box">
	<div id="content"></div>
</div>

<script type='text/html' id='shuoTemplate'>
<%for(var item in templateData){%>
<%item = templateData[item]%>
<a class="say_box" href="<%=item['url']%>">
        <div class="user_info">
            <img onerror="src='{skin:images/avatar.png}'" src="<%=item['head_ico']%>">
            <div class="user_info_text">
                <strong><%=item['username']%></strong>
                <p><span class="started"><%=item['date']%></span><span>婚期:<% if(item['wedding_data']){%><%=item['wedding_data']%><% }else{%>婚期未设置<% }%></span></p>
            </div>
        </div>
		<% if(item['imgs'].length > 0){ %>
        <div class="pic_newly_box">
        	<div class='post <% if(item['imgs'].length == 1){%>xs0-1<% }else if(item['imgs'].length == 2 || item['imgs'].length == 4){%>xs2-4<% }%>'>
			<% for(var im in item['imgs']){%>
            <img src="<%=item['imgs'][im]%>" data-big="<%=item['bigimg'][im]%>">
			<% }%>
            </div>
        </div>
		<% }%>
        <div class="newly_text"><%=#item['content']%></div>
        <div class="newly_bottom">
			<% if(item['location']){ %>
        	<i class="iconfont icon-dingwei"><%=item['location']%></i>
			<% }%>
            <em class="iconfont icon-heart"><%=item['comments']%></em>
            <span class="iconfont icon-speak"><%=item['zans']%></span>
        </div>
    </a>
<%}%>
</script>

var page = 1;
var me = $('.newly_box').dropload({
	scrollArea : window,
	autoLoad: true,
	domDown : {
		domLoad : '<div class="coolc-load">&nbsp;</div>',
		domNoData : '<div class="coolc-noData"><span>到底了暂无数据</span></div>'
	},
	loadUpFn : function(){
		$.getJSON('{url:/ajax_data/shuoshuo_data}',{page:1},function(data){
			var shuoHtml = template.render('shuoTemplate',{"templateData":data});
			$('#content').html(shuoHtml);
			me.resetload();
		});	
	},
	loadDownFn : function(){
		$.getJSON('{url:/ajax_data/shuoshuo_data}',{page:page},function(data){
			if(data.length > 0){
				var shuoHtml = template.render('shuoTemplate',{"templateData":data});
				$('#content').append(shuoHtml);
				page++;
			}else{
				me.noData(true);
			}
			me.resetload();
		});	
	}
});
原创声明
本站部分文章基于互联网的整理,我们会把真正“有用/优质”的文章整理提供给各位开发者。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
本文链接:http://www.jiecseo.com/news/show_73439.html