iscroll.js遇到的问题

来源:互联网 发布:5357端口是什么 编辑:程序博客网 时间:2024/05/18 16:38

1.在一个页面中需要点击tab切换,而且每个切换的内容都需要下拉刷新加载,这个时候需要在点击的时候用到myScroll.refresh();这个函数,刷新iScroll.js这个函数。

2.在页面中有input等需要输入的表单时,表单会无法输入,这时需要在代码最后加上以下这段函数,

function allowFormsInIscroll(){
[].slice.call(document.querySelectorAll(‘input, select, button’)).forEach(function(el){
   el.addEventListener((‘ontouchstart’ in window)?’touchstart’:’mousedown’, function(e){
   e.stopPropagation();
})
})
}
document.addEventListener(‘touchmove’, function (e) { e.preventDefault(); }, false);
document.addEventListener(‘DOMContentLoaded’, function () { setTimeout(loaded, 200);allowFormsInIscroll(); }, false);

3.在页面中点击某个元素时,会触发两次,这时可以用

$(“.pp_right a”).one(‘click’,function(){
alert(1);
})

即jq的one()方法解决