//创建node
var createFragment = function(count) {
var fragment = document.createDocumentFragment();
var li;
for (var i = 0; i < count; i++) {
li = document.createElement('li');
li.className = 'mui-table-view-cell';
li.innerHTML = '<div class="mui-slider-handle">ddd'+
'<img class="mui-media-object mui-pull-left" data-lazyload="d">ddd'+
'<div class="mui-media-body"'+
'<p class="mui-pull-right">'+'</p>'+
'<p class="mui-ellipsis">'+'</p>'+
'</div>'+
'</div>'+
'<div class="mui-slider-right mui-disabled"><a class="mui-btn mui-btn-red">delete</a></div>';
fragment.appendChild(li);
}
return fragment;
};
//监听
var btnArray = ['OK', 'Cancel'];
mui('.mui-slider-right').on('tap', '.mui-btn', function(event) {
var elem = this;
var li = elem.parentNode.parentNode;
var result = jQuery(li).attr("id");
console.log(result);
mui.confirm('确认删除该条记录?', 'Hello MUI', btnArray, function(e) {
if (e.index == 0) {
li.parentNode.removeChild(li);
} else {
setTimeout(function() {
mui.swipeoutClose(li);
}, 0);
}
});
});
document.querySelector('.mui-slider-handle').addEventListener("doubletap", function(t){
console.log("jump");
var result = jQuery(this.parentNode).attr("id");
console.log(result);
jumpToChat();
},false);
如上,无法监听懒加载的点击事件
1 个回复
赵梦欢 - 专注前端,乐于分享!
doubletap 默认为false,需要在mui.init中开启
手势事件