我在jquery mobile中向面板动态添加数据,但是在第一次面板无法工作时加载页面,但是如果我刷新它就会开始正常工作。
var prof = '';
var panel = '';
$(document).one('pagecreate', '[data-role="page"]', function () {
if (sessionStorage.getItem('sessionid') !== '' || sessionStorage.getItem('sessionid') !== null && sessionStorage.getItem('user_id') !== '' || sessionStorage.getItem('user_id') !== null) {
var jxhr = $.post(getdetails + '' + 'Users', {
session_id: sessionStorage.sessionid,
id: sessionStorage.getItem('user_id')
}, function (data) {
var ourhtml = getRecordDetailProfileCheck(data);
prof = "<div style='text-align:center;'>" + ourhtml + "</div><div></div>";
sessionStorage.setItem('prof', prof);
panel = '<div data-role="panel" data-theme="b" data-display="push" id="mypanel"><ul data-role="listview" data-role="none" class="ulpanel"><br/><a href="#profile"><div id="panelimage"></div></a>' + prof + '<div><br/></div><li><a href="#viewquestions"><i class="lIcon main"></i>MAIN SERVICE</a></li><li><a href="#specialevents"><i class="lIcon main"></i>SPECIAL EVENTS</a></li><li><a href="#lifegroup"><i class="lIcon main"></i>LIFE GROUPS</a></li><li><a href="#sundaygroup"><i class="lIcon main"></i>SUNDAY SCHOOL</a></li><li><a href="#mainservice"><i class="lIcon main"></i>PRAYER & PRAISE</a></li><li><a href="#factory"><i class="lIcon main"></i>FACTORY & YOUTH MIX</a></li><li><a href="#volunteer"><i class="lIcon main"></i>VOLUNTEER</a></li></ul></div>';
$.mobile.pageContainer.prepend(panel);
$("#mypanel").panel().enhanceWithin();
var img = '';
var va = getRecordIdPicture(data);
if (va !== '') {
img = file + "?session_id=" + sessionStorage.getItem('sessionid') + "&id=" + va;
} else {
img = 'images/man.png';
}
$("#mypanel #panelimage").attr('style', 'margin: 0 auto;text-align:center;width: 128px;height: 128px;border-style: solid;-webkit-border-radius: 100px;-moz-border-radius: 100px;background: url(' + img + ') no-repeat 100% 100%');
// console.log(data);
});
} else {
for (var i = 0; i < sessionStorage.length; i++) {
var key = sessionStorage.key(i);
if (/foo/.test(key)) {
sessionStorage.removeItem(key);
}
}
$.mobile.changePage("#one", {
transition: "slide",
reverse: false,
changeHash: true
});
}
});
致电小组:
<div data-role="header" data-position="fixed" data-tap-toggle="false" data-theme='b'>
<a href='#mypanel' data-role='button' data-iconpos='left' data-inline='true'><i class='fa fa-bars'></i></a>
<h1 style="text-align: center;"><img src="images/pcc.png" height="26"/></h1>
<a href="#" class="lnklogout" data-ajax="false"><i class='fa fa-power-off'></i></a>
</div>
我已经尝试了一切我觉得会话没有被设置?请有人帮忙
由于