使用jquery.more.js来实现点击底部更多后, 底部加载出新的数据
<div class="bus-nav-bar ft12">
<div class="navt bor-r-c pos-rel {if $int == 0}fwbold{/if}"><a href="portal.php?mod=merchant&action=voucherlist&int=0">全部订单</a><em class="pos-abs"></em></div>
<div class="navt bor-r-c pos-rel {if $int == 7}fwbold{/if}"><a href="portal.php?mod=merchant&action=voucherlist&int=7">最近7天订单</a><em class="pos-abs"></em></div>
<div class="navt pos-rel {if $int == 30}fwbold{/if}"><a href="portal.php?mod=merchant&action=voucherlist&int=30">最近一个月订单</a><em class="pos-abs"></em></div>
</div>
<div class="bus94 m-0-auto" id="vlist">
<ul class="busbox ft12">
<li class="headh2">消费确认码:<span class="checkcode"></span></li>
<li class="headh2">电 子 串 码:<span class="password"></span></li>
<li class="headh2">商 品 名 称:<span class="productname"></span></li>
<li class="headh2">商 品 价 格:¥<span class="price"></span></li>
<li class="headh2">验 证 时 间:<span class="checktime"></span></li>
</ul>
<div id="get_more" class="txtcent button ft12">更多</div>
</div> <script type=text/javascript src="{STATICURL}js/mobile/jquery.more.js"></script>
<script type="text/javascript">
jQuery(function() {
jQuery('#vlist').more({
"url": 'portal.php?mod=ajax&do=mvoucher',
"data":{"int":"{$int}"},
"template": ".busbox",
"trigger": "#get_more"
});
});
</script>
php代码
//手机商户已验证代金券列表
$int = intval($_GET['int']);
$int = in_array($int, array(0,7,30)) ? $int : 0;
$params = null;
if($int == 7){
$params = array('starttime'=>date("Y-m-d",strtotime("-7days")));
}elseif($int == 30){
$params = array('starttime'=>date("Y-m-d",strtotime("-30days")));
}
$last = intval($_GET['last'])/5 + 1;
$data = merchant_checked_list(107, $params, 5, $last);
if($data && $data['data']){
foreach($data['data'] as $key => $value){
$data['data'][$key]['password'] = decrypt($value['password']);
$data['data'][$key]['price'] = deal_money($value['price']);
$data['data'][$key]['checktime'] = date('Y-m-d H:i:s', $value['checktime']);
}
echo json_encode($data['data']);
}
jquery.more.js
/**
* 调用参数,方法如:$('#more').more({'url': 'data.php'});
* amount :'10' 每次显示记录数
* url :'comments.php' 请求后台的地址
* data:{}, 自定义参数
* template:'.single_item' html记录DIV的class属性
* trigger :'#get_more' 触发加载更多记录的class属性
* scroll :'false' 是否支持滚动触发加载
* offset :'100' 滚动触发加载时的偏移量
*/
(function($) {
var target = null;
var template = null;
var lock = false;
var variables = {
'last': 0
};
var settings = {
'amount': '8',
'url': '',
'template': '.single_item',
'data':{},
'trigger': '#get_more',
'scroll': 'false',
'offset': '100'
};
var methods = {
init: function(options) {
return this.each(function() {
if (options) {
$.extend(settings, options);
}
template = $(this).children(settings.template).wrap('<div/>').parent();
template.css('display', 'none');
$(this).append('<div class="loading ft12" id="waitbox"><img src="/static/m/images/loading.gif" width="19" height="19" />载入中..</div>');
$(this).children(settings.template).remove();
target = $(this);
if (settings.scroll == 'false') {
$(this).find(settings.trigger).bind('click.more', methods.get_data);
$(this).more('get_data');
} else {
if ($(this).height() <= $(this).attr('scrollHeight')) {
target.more('get_data', settings.amount * 2);
}
$(this).bind('scroll.more', methods.check_scroll);
}
});
},
check_scroll: function() {
if ((target.scrollTop() + target.height() + parseInt(settings.offset)) >= target.attr('scrollHeight') && lock == false) {
target.more('get_data');
}
},
remove: function() {
target.children(settings.trigger).unbind('.more');
target.unbind('.more');
target.children(settings.trigger).remove();
},
add_elements: function(data) {
var root = target;
var counter = 0;
if (data) {
$(data).each(function() {
counter++;
var t = template;
$.each(this, function(key, value) {
if (t.find('.' + key))
t.find('.' + key).html(value);
});
if (settings.scroll == 'true') {
root.children('.more_loader_spinner').before(t.html());
} else {
root.children(settings.trigger).before(t.html());
}
root.children(settings.template + ':last').attr('id', 'more_element_' + ((variables.last++) + 1));
});
} else {
methods.remove();
}
target.children('.more_loader_spinner').css('display', 'none');
if (counter < settings.amount)
methods.remove();
},
get_data: function() {
var ile;
lock = true;
target.children(".more_loader_spinner").css('display', 'block');
$(settings.trigger).css('display', 'none');
if (typeof (arguments[0]) == 'number')
ile = arguments[0];
else {
ile = settings.amount;
}
var postdata = settings.data;
postdata['last'] = variables.last;
postdata['amount'] = ile;
$.post(settings.url, postdata, function(data) {
$(settings.trigger).css('display', 'block');
methods.add_elements(data);
lock = false;
$("#waitbox").remove();
}, 'json');
}
};
$.fn.more = function(method) {
if (methods[method])
return methods[ method ].apply(this, Array.prototype.slice.call(arguments, 1));
else if (typeof method == 'object' || !method)
return methods.init.apply(this, arguments);
else
$.error('Method ' + method + ' does not exist!');
}
})(jQuery)
使用jquery.more.js来实现点击底部更多后, 底部加载出新的数据的更多相关文章
- jQuery的JS库在本地运行项目时提示无法加载
最近公司有个项目在我本地运行时引用本地的jquery.js,浏览器提示无法加载 <script src="/js/newperson/jquery-1.11.3.min.js" ...
- jquery/原生js/css3 实现瀑布流以及下拉底部加载
思路: style: <style type="text/css"> body,html{ margin:; padding:; } #container{ posit ...
- jQuery Mobile页面跳转后未加载外部JS(转)
http://thewaychung.iteye.com/blog/1807447 在使用jQuery Mobile进行Web开发中,当页面跳转时(pageA => pageB),在pageB中 ...
- jQuery Mobile页面跳转后未加载外部JS原因分析及解决
在使用jQuery Mobile进行Web开发中,当页面跳转时(pageA => pageB),在pageB中引用的JS并未成功运行.因为,JQM并为将整个页面加载到当前的dom中,仅将data ...
- ajax实现简单的点击左侧菜单,右侧加载不同网页
实现:ajax实现点击左侧菜单,右侧加载不同网页(在整个页面无刷新的情况下实现右侧局部刷新,用到ajax注意需要在服务器环境下运行,从HBuilder自带的服务器中打开浏览效果即可) 原理:ajax的 ...
- web实现点击左侧导航,右侧加载不同的网页(这种布局多用于后台管理系统)
(1)实现方法:采用ajax实现点击左侧菜单,右侧加载不同网页(在整个页面无刷新的情况下实现右侧局部刷新,用到ajax注意需要在服务器环境下运行,从HBuilder自带的服务器中打开浏览效果即可) ( ...
- 使用jquery结合ajax做下拉刷新页面,上拉加载页面,俗称分页
jquery结合iscroll.js做下拉刷新页面,上拉加载页面 先上代码,里面都有注释这就不一一说明了 <!DOCTYPE html> <html lang="en&qu ...
- 为不同分辨率单独做样式文件,在页面头部用js判断分辨率后动态加载定义好的样式文件
为不同分辨率单独做样式文件,在页面头部用js判断分辨率后动态加载定义好的样式文件.样式文件命名格式如:forms[_屏幕宽度].css,样式文件中只需重新定义文本框和下拉框的宽度即可. 在包含的头文件 ...
- jquery实现简单瀑布流布局(续):图片懒加载
# jquery实现简单瀑布流布局(续):图片懒加载 这篇文章是jquery实现简单瀑布流布局思想的小小扩展.代码基于前作的代码继续完善. 图片懒加载就是符合某些条件时才触发图片的加载.最常见的具体表 ...
随机推荐
- 详解SID之终结篇
今天测试某款监控软件时遇到一个比较棘手的问题,这款软件需要在被监控端安装客户端程序.成功在第一个节点安装好客户端后问题出现了,在其他节点安装时报错无法安装.软件报的错误信息无从下手且系统日志也看不出什 ...
- RAC7——vip的理解
VIP特点: 1 VIP是在clusterware安装最后阶段,通过脚本VIPCA创建的: 2 VIP作为一个Nodeapps类型的CRS Resource注册到OCR中,并由CRS维护状态: 3 V ...
- vue-cli、webpack提取第三方库-----DllPlugin、DllReferencePlugin
需要安装的插件有 extract-text-webpack-plugin assets-webpack-plugin clean-webpack-plugin npm install extract- ...
- Windows Phone Runtime Component 中的类型转换
Windows Phone Runtime Component 是Windows Phone 平台用来写C++类库的项目类型. 主要目的是让C#和C++进行互操作,引用历史的C++代码,保护知识产权, ...
- EF 的一些不常用的功能
1.Add-Migration Initia-IgnoreChanges 生成已有数据库初始化代码 2.update-database -verbose 升级数据库并显示sql语句 3.Update- ...
- BASIC-27_蓝桥杯_2n皇后问题
题目: 问题描述 给定一个n*n的棋盘,棋盘中有一些位置不能放皇后.现在要向棋盘中放入n个黑皇后和n个白皇后,使任意的两个黑皇后都不在同一行.同一列或同一条对角线上,任意的两个白皇后都不在同一行.同一 ...
- ES之七:配置文件详解
安装流程 http://www.elasticsearch.org/overview/elkdownloads/下载对应系统的安装包(我下载的是tar的),下载解压以后运行es根目录下bin目录的el ...
- 杂项:BugFree
ylbtech-杂项:BugFree BugFree是借鉴微软的研发流程和Bug管理理念,使用PHP+MySQL独立写出的一个Bug管理系统.简单实用.免费并且开放源代码(遵循GNU GPL). 命名 ...
- centos自带的dvd中的官方base源,丢失了可以复制下面的内容
/etc/yum.repos.d/CentOS-Base.repo文件中的内容,同样适用于centos6 [base]name=CentOS-$releasever - Basemirrorlist= ...
- javascript的冻结对象之freeze(),isFrozen()方法
最严格的对象保护措施就是冻结对象了.冻结过后的对象,即不可以扩展,原有对象也不可以删除,因为[Writable]=false,所以对象的属性不可修改. 示例一: var person={name:&q ...