一款支持左右两边滑动删除的mui手机触屏滑动删除代码,移动端触屏滑动列表项目显示删除按钮,点击进行删除。
js代码
<script src="js/mui.min.js"></script>
<script>
mui.init();
(function($) {
//$.swipeoutOpen(el,direction)//打开指定列的滑动菜单,el:指定列的dom对象,direction:取值left|right,指定打开的是左侧或右侧滑动菜单
//$.swipeoutClose(el);//关闭指定列的滑动菜单,el:指定列的dom对象
// setTimeout(function() {
// $.swipeoutOpen(document.getElementById("OA_task_1").querySelector('li:last-child'), 'left');
// setTimeout(function() {
// $.swipeoutClose(document.getElementById("OA_task_1").querySelector('li:last-child'));
// }, 1000);
// }, 1000);
//第一个demo,拖拽后显示操作图标,点击操作图标删除元素;
$('#OA_task_1').on('tap', '.mui-btn', function(event) {
var elem = this;
var li = elem.parentNode.parentNode;
mui.confirm('<div class="text"><p class="icon-information"></p><h3>确定删除此条消息?</h3><span>REMIND</span></div>', 'Hello MUI', btnArray, function(e) {
if (e.index == 0) {
li.parentNode.removeChild(li);
} else {
setTimeout(function() {
$.swipeoutClose(li);
}, 0);
}
});
});
var btnArray = ['确认', '取消'];
//第二个demo,向左拖拽后显示操作图标,释放后自动触发的业务逻辑
$('#OA_task_2').on('slideleft', '.mui-table-view-cell', function(event) {
var elem = this;
mui.confirm('<div class="text"><h3>确定删除此条消息?</h3><span>REMIND</span></div>', 'Hello MUI', btnArray, function(e) {
if (e.index == 0) {
elem.parentNode.removeChild(elem);
} else {
setTimeout(function() {
$.swipeoutClose(elem);
}, 0);
}
});
});
$('#OA_task_2').on('slideleft', '.mui-table-view-cell', function(event) {
var elem = this;
mui.confirm('<div class="text"><p class="icon-information"></p><h3>确定删除此条消息?</h3><span>REMIND</span></div>', 'Hello MUI', btnArray, function(e) {
if (e.index == 0) {
elem.parentNode.removeChild(elem);
} else {
setTimeout(function() {
$.swipeoutClose(elem);
}, 0);
}
});
});
//第二个demo,向右拖拽后显示操作图标,释放后自动触发的业务逻辑
$('#OA_task_2').on('slideright', '.mui-table-view-cell', function(event) {
var elem = this;
mui.confirm('<div class="text"><p class="icon-information"></p><h3>确定删除此条消息?</h3><span>REMIND</span></div>', 'Hello MUI', btnArray, function(e) {
if (e.index == 0) {
elem.parentNode.removeChild(elem);
} else {
setTimeout(function() {
$.swipeoutClose(elem);
}, 0);
}
});
});
})(mui);
</script>
系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791