加载后刷新jquery移动页面
加载后刷新jquery移动页面,jquery,html,jquery-mobile,iscroll,jquery-mobile-ajax,Jquery,Html,Jquery Mobile,Iscroll,Jquery Mobile Ajax,我有两页,A和B: -->登录页。 B-->包含HTML元素和iScoll“pull to refreash”代码。 evrey thing工作正常,但当我从A登录到B时,iScroll内容不会显示,如果我刷新了B页,内容会显示出来,并且工作正常,这是iScroll代码: <script type="text/javascript"> var myScroll, pullDownEl, pullDownOffset, generatedCount = 0;
我有两页,A和B:
-->登录页。
B-->包含HTML元素和iScoll“pull to refreash”代码。
evrey thing工作正常,但当我从A登录到B时,iScroll内容不会显示,如果我刷新了B页,内容会显示出来,并且工作正常,这是iScroll代码:
<script type="text/javascript">
var myScroll,
pullDownEl, pullDownOffset,
generatedCount = 0;
function pullDownAction() {
setTimeout(function () {
var el, li, i;
el = document.getElementById('thelist');
var returnedLIs = "";
for (i = 0; i < 3; i++) {
returnedLIs += '<li><a href="#" data-ajax="false" class="PDFLink"></a></li>';
}
$(returnedLIs).prependTo($('#thelist'));
myScroll.refresh();
}, 0);
}
function loaded() {
pullDownEl = document.getElementById('pullDown');
pullDownOffset = pullDownEl.offsetHeight;
myScroll = new iScroll('wrapper', {
hideScrollbar:false,
useTransition: true,
topOffset: pullDownOffset,
onRefresh: function () {
if (pullDownEl.className.match('loading')) {
pullDownEl.className = '';
pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';
}
},
onScrollMove: function () {
if (this.y > 5 && !pullDownEl.className.match('flip')) {
pullDownEl.className = 'flip';
pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Release to refresh...';
this.minScrollY = 0;
} else if (this.y < 5 && pullDownEl.className.match('flip')) {
pullDownEl.className = '';
pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';
this.minScrollY = -pullDownOffset;
}
},
onScrollEnd: function () {
if (pullDownEl.className.match('flip')) {
pullDownEl.className = 'loading';
pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Loading...';
pullDownAction(); // Execute custom function (ajax call?)
}
}
});
setTimeout(function () { document.getElementById('wrapper').style.left = '0'; }, 800);
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false);
</script>
var Myscoll,
下拉式,下拉式偏移,
生成计数=0;
函数pullDownAction(){
setTimeout(函数(){
var el,li,i;
el=document.getElementById('thelist');
var returnedLIs=“”;
对于(i=0;i<3;i++){
返回的LIS+='';
}
$(returnedLIs).prependTo($('thelist'));
myScroll.refresh();
}, 0);
}
函数加载(){
pullDownEl=document.getElementById('pullDown');
pullDownOffset=pullDownEl.offsetHeight;
myScroll=new iScroll('wrapper'{
hideScrollbar:false,
对,,
拓扑偏移:下拉偏移,
onRefresh:function(){
if(pullDownEl.className.match('load')){
pullDownEl.className='';
pullDownEl.querySelector('.pullDownLabel').innerHTML='pulldown to refresh…';
}
},
onScrollMove:函数(){
if(this.y>5&&!pullDownEl.className.match('flip')){
pullDownEl.className='flip';
pullDownEl.querySelector('.pullDownLabel').innerHTML='releasetoresh…';
这个.minscorly=0;
}else if(this.y<5&&pullDownEl.className.match('flip')){
pullDownEl.className='';
pullDownEl.querySelector('.pullDownLabel').innerHTML='pulldown to refresh…';
this.minscorly=-pulldowncoffset;
}
},
onScrollEnd:函数(){
if(pullDownEl.className.match('flip')){
pullDownEl.className='loading';
pullDownEl.querySelector('.pullDownLabel').innerHTML='Loading…';
pullDownAction();//执行自定义函数(ajax调用?)
}
}
});
setTimeout(函数(){document.getElementById('wrapper').style.left='0';},800);
}
addEventListener('touchmove',函数(e){e.preventDefault();},false);
addEventListener('DOMContentLoaded',function(){setTimeout(loaded,200);},false);
有人能帮忙吗
编辑A.aspx-->登录页面的
部分:
编辑B.aspx的部分:
var Myscoll,
下拉式,下拉式偏移,
生成计数=0;
函数pullDownAction(){
setTimeout(函数(){
var el,li,i;
el=document.getElementById('thelist');
var returnedLIs=“”;
对于(i=0;i<3;i++){
返回的LIS+='';
}
$(returnedLIs).prependTo($('thelist'));
myScroll.refresh();
}, 0);
}
函数加载(){
pullDownEl=document.getElementById('pullDown');
pullDownOffset=pullDownEl.offsetHeight;
myScroll=new iScroll('wrapper'{
hideScrollbar:false,
对,,
拓扑偏移:下拉偏移,
onRefresh:function(){
if(pullDownEl.className.match('load')){
pullDownEl.className='';
pullDownEl.querySelector('.pullDownLabel').innerHTML='pulldown to refresh…';
}
},
onScrollMove:函数(){
if(this.y>5&&!pullDownEl.className.match('flip')){
pullDownEl.className='flip';
pullDownEl.querySelector('.pullDownLabel').innerHTML='releasetoresh…';
这个.minscorly=0;
}else if(this.y<5&&pullDownEl.className.match('flip')){
pullDownEl.className='';
pullDownEl.querySelector('.pullDownLabel').innerHTML='pulldown to refresh…';
this.minscorly=-pulldowncoffset;
}
},
onScrollEnd:函数(){
if(pullDownEl.className.match('flip')){
pullDownEl.className='loading';
pullDownEl.querySelector('.pullDownLabel').innerHTML='Loading…';
pullDownAction();//执行自定义函数(ajax调用?)
}
}
});
setTimeout(函数(){document.getElementById('wrapper').style.left='0';},800);
}
addEventListener('touchmove',函数(e){e.preventDefault();},false);
addEventListener('DOMContentLoaded',function(){setTimeout(loaded,200);},false);
让我解释一下发生了什么
您有两个单独的HTML页面。每个页面都有一个包含javascript内容的标题
问题在于jQuery Mobile如何处理页面加载。只有第一页完全加载。当下一个页面即将加载时,只有它的主体被加载到DOM中,其余部分被丢弃。这是因为第一页已经在DOM中了,没有必要在DOM中添加标题
有几种方法可以解决这一问题:
- 将第二页javascript移到第一页的开头
- 将第二页javascript移动到第二页正文
- 进行页面转换时,将以下属性添加到链接中:
<head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" /> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script> <link href="css/Site.css" rel="stylesheet" type="text/css" /> <!-- Validition Library --> <script src="Validate/jquery.validVal-4.3.3.js" type="text/javascript"></script> </head>
<head runat="server"> <%--PULL TO REFREASH--%> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <%--PULL TO REFREASH--%> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" /> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script> <%--PULL TO REFREASH--%> <script type="text/javascript" src="jq/iscroll.js"></script> <%--PULL TO REFREASH--%> <link href="css/Site.css" rel="stylesheet" type="text/css" /> <%--pull to refresh--%> <script type="text/javascript"> var myScroll, pullDownEl, pullDownOffset, generatedCount = 0; function pullDownAction() { setTimeout(function () { var el, li, i; el = document.getElementById('thelist'); var returnedLIs = ""; for (i = 0; i < 3; i++) { returnedLIs += '<li><a href="#" data-ajax="false" class="PDFLink"></a></li>'; } $(returnedLIs).prependTo($('#thelist')); myScroll.refresh(); }, 0); } function loaded() { pullDownEl = document.getElementById('pullDown'); pullDownOffset = pullDownEl.offsetHeight; myScroll = new iScroll('wrapper', { hideScrollbar:false, useTransition: true, topOffset: pullDownOffset, onRefresh: function () { if (pullDownEl.className.match('loading')) { pullDownEl.className = ''; pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...'; } }, onScrollMove: function () { if (this.y > 5 && !pullDownEl.className.match('flip')) { pullDownEl.className = 'flip'; pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Release to refresh...'; this.minScrollY = 0; } else if (this.y < 5 && pullDownEl.className.match('flip')) { pullDownEl.className = ''; pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...'; this.minScrollY = -pullDownOffset; } }, onScrollEnd: function () { if (pullDownEl.className.match('flip')) { pullDownEl.className = 'loading'; pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Loading...'; pullDownAction(); // Execute custom function (ajax call?) } } }); setTimeout(function () { document.getElementById('wrapper').style.left = '0'; }, 800); } document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false); document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false); </script> <%--pull to refresh--%> </head>