mui.init({ gestureConfig: { longtap: true, //默认为false,激活长按按钮 } });
上面为mui页面初始化时,激活长按
js如下
// 使用mui的长按事件 mui('#ul_li_group').on('longtap', 'li', function () {
//监听ul列表,长按触发拿取列表第一个元素状态 var divs = this.children[0]; var state = divs.title.split(",")[1]; if(state==0){ mui.confirm('请选择您的操作!!!', '文件详情', ['取消','查看'], function (e) { if (e.index == 1) { //查看。此处mui-popover模块儿的弹出和关闭都是mui('#picture').popover('toggle'); mui('#picture').popover('toggle');//打开div中的mui-popover模块儿 document.getElementById("startshare").addEventListener('tap',function(){ var str = document.getElementById("formtitle").title;
var radio_tag = document.getElementsByName("radio1");
var type="";
for(var i=0;i<radio_tag.length;i++){
if(radio_tag[i].checked){
type = radio_tag[i].value;
}
}
var term="";
var radio_tag2 = document.getElementsByName("radio2");
for(var i=0;i<radio_tag2.length;i++){
if(radio_tag2[i].checked){
term = radio_tag2[i].value;
}
}
//确认后,关闭 mui('#picture').popover('toggle');
//开始传输后台数据 mui.ajax('url', { data : {"str":str,"type":type,"term":term}, beforeSend: function() { plus.nativeUI.showWaiting("正在加载中,请稍等..."); }, complete: function() { plus.nativeUI.closeWaiting(); }, type: "POST", dataType: "json", success: function (data) { if(data == "1"){ mui.toast('成功'); //location.reload(true);刷新页面 }else{ mui.toast('失败'); } } }) }); } }) } })
mui-popover的div代码如下
<div id="picture" class="mui-popover mui-popover-action "> <div class="mui-table-view"> <h3>文件(夹):<span id="formtitle" title=""></span></h3> <hr /> <div style="float: left;margin-left: 10px;"> <span>查看形式</span> <input type="radio" name="radio1" value="1" checked>有密码 <input type="radio" name="radio1" value="0">无密码 </div> <div class="clear"></div> <br /> <div style="float: left;margin-left: 10px;"> <span>有效期</span> <input type="radio" name="radio2" value="0" checked>永久有效 <input type="radio" name="radio2" value="7">7天 <input type="radio" name="radio2" value="1">1天 </div> <br /><hr /> <div style="float: left;margin-left: 20%;margin-bottom: 5px;"> <button type="button" class="btn" id="createshare"> 复制秘密链接 </button> </div> <div > <button type="button" class="btn" id="closeshare"> 取消 </button> </div> </div> </div>