yicixing
yicixing
  • 发布:2015-12-22 16:35
  • 更新:2015-12-22 18:05
  • 阅读:3477

【报bug】下拉刷新界面(pullrefresh_sub.html),通过手机浏览器,不能触发点击事件。

分类:MUI

hello mui -demo, 下拉刷新 界面(pullrefresh_sub.html),通过手机浏览器打开,不能触发点击事件。
web界面为:http://www.dcloud.io/hellomui/examples/pullrefresh_sub.html。此界面在电脑浏览器中点击正常。但是在手机浏览器中打开此web,点击table-view-cell后,test函数 不能响应,只在界面最左边有响应。

经测试,是pullrefresh 的刷新功能影响的。怎么能既实现下拉刷新,又有点击事件?
测试代码为官方demo里的pullrefresh_sub.html 代码中 添加table-view-cell的点击事件,代码如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello MUI</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<link rel="stylesheet" href="../css/mui.min.css">
</head>

<body>
<!--下拉刷新容器-->
<div id="pullrefresh" class="mui-content mui-scroll-wrapper">

<div class="mui-scroll">
<!--数据列表-->
<ul class="mui-table-view mui-table-view-chevron">
</ul>
</div>
</div>
<script src="../js/mui.min.js"></script>
<script>
mui.init({
pullRefresh: {
container: '#pullrefresh',
down: {
callback: pulldownRefresh
},
up: {
contentrefresh: '正在加载...',
callback: pullupRefresh
}
}
});
/**

  • 下拉刷新具体业务实现
    */
    function pulldownRefresh() {
    setTimeout(function() {
    var table = document.body.querySelector('.mui-table-view');
    var cells = document.body.querySelectorAll('.mui-table-view-cell');
    for (var i = cells.length, len = i + 3; i < len; i++) {
    var li = document.createElement('li');
    li.className = 'mui-table-view-cell';
    li.innerHTML = '<a class="mui-navigate-right">Item ' + (i + 1) + '</a>';
    table.insertBefore(li, table.firstChild);
    }
    mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
    }, 1500);
    }
    var count = 0;

function pullupRefresh() {
setTimeout(function() {
mui('#pullrefresh').pullRefresh().endPullupToRefresh((++count > 2));
var table = document.body.querySelector('.mui-table-view');
var cells = document.body.querySelectorAll('.mui-table-view-cell');
for (var i = cells.length, len = i + 20; i < len; i++) {
var li = document.createElement('li');
li.className = 'mui-table-view-cell';
li.innerHTML = '<a class="mui-navigate-right">Item ' + (i + 1) + '</a>';
table.appendChild(li);
li.id = (i + 1);

//添加自定义点击事件
li.setAttribute("onclick","test(id)");
}
}, 1500);
}
if (mui.os.plus) {
mui.plusReady(function() {
setTimeout(function() {
mui('#pullrefresh').pullRefresh().pullupLoading();
}, 1000);

});
} else {
mui.ready(function() {
mui('#pullrefresh').pullRefresh().pullupLoading();
});
}
//添加自定义点击事件
function test(id){
console.log("点击了Item "+id);
}
</script>
</body>

</html>

2015-12-22 16:35 负责人:无 分享
已邀请:
我勒个去

我勒个去

用tap

  • yicixing (作者)

    请教下,原理是什么啊?为什么用了pullrefresh后,onclick不能响应?

    2015-12-23 09:25

  • 我勒个去

    所有点击事件最好用官方的监听tap吧

    2015-12-24 00:58

该问题目前已经被锁定, 无法添加新回复