jQuery Mobile을 사용하여 webapp을 작성하여 localStorage에 레코드를로드하고 페이지가 처음에는 원격 JSON 파일에서 listview를 작성하는 함수를 호출합니다. 만든 (페이지에 live.pagecreate()
이벤트 사용). 이 함수의 시작 부분에 jQuery Mobile 메소드 $.mobile.showPageLoadingMsg()
과 $.mobile.hidePageLoadingMsg()
이 함수의 끝에 있습니다.jQuery Mobile showPageLoadingMsg()/hidePageLoadingMsg() 메소드가 초기 페이지에서 작동하지 않습니다. loadn
초기에 iOS 4.3 Safari, Chrome 13 및 Firefox 5가 설치된 iPhone 4에서 로딩 메시지가 표시되지 않습니다. 그러나 페이지에 새로 고침 단추가 있습니다. 이 버튼은 localStorage의 관련 레코드를 지우고 처음에는 listview를 채우는 데 사용 된 동일한 함수를 호출합니다. 그러나 새로 고침 버튼에서 동일한 기능을 호출하면 showPageLoadingMsg()
과 hidePageLoadingMsg()
이 모두 올바르게 작동하고로드 중 화면이 나타나고 사라집니다. 내가 여기서 뭔가를 놓치고 있니?
ETA 여기에 코드의 요지가 있습니다 (실제 코드 앞에 없으면 더 필요합니다 오늘 밤에 넣을 것입니다). 이 핸들러를 들어
function loadListView(){
$.mobile.showPageLoadingMsg();
//ajax call to pull JSON
//$.each loop to load localStorage and listview
$.listview.refresh('list');
$.mobile.hidePageLoadingMsg();
}
$(#listpage).live('pagecreate', function(event){
loadListView(); // showPageLoadingMsg() and hidePageLoadingMsg do not work when the function is called here
});
function clearList(){
//for loop that clears each item in localStorage that matches the key prefix set in loadListView
}
//runs when refresh button is clicked
$('listrefresh').live('click',function(){
clearList();
loadListView(); //showPageLoadingMsg() and hidePageLoadingMsg() work when the function is called here
});
질문을 편집하고 시도한 코드를 추가 할 수 있습니까? –
@Phill 위의 일반 코드를 추가했습니다. 필요하다면 실제 코드를 나중에 추가 할 수 있습니다. – scottoliver
그냥 지적하자면 .click을 사용하지 말고 사용해야합니다. $ ('listrefresh'). live ('click', function() {/ * 여기에 코드 * /}); jquery 모바일 베타 1을 사용하는 경우 1. 클릭 대신 vclick을 사용하십시오. – root