简体   繁体   中英

Stop caching in jquery mobile with cordova on history back()

Our team made an app using cordova and jquery mobile. We kept every single page in different html files. Program navigates using window.location. But we have a small problem. App has a calendar where user can choose to add an event and directed to a form page. On this page user fill a form and post the new event to database and redirected to calendar page with historyback() function. But because the page is cached new event doesn't appear until you navigate there from a different page. How can we solve this problem? What is the best way to manage navigation in jquery mobile.

Instead of using historyback() for going back, use the page navigation feature of jquery mobile.The same way which you are using for going from page 1 to page 2. U can use the same to come back from page 2 to page 1.

syntax:- jQuery.mobile.changePage( to [, options ] )

Ex:- $.mobile.changePage( "#pageId", { transition: "slideup" });

Check the active page when user clicks the back button and write a condition there.

document.addEventListener("backbutton", function(e){
    if($.mobile.activePage.is('#login_page')){
        e.preventDefault();
    }
    else {
       $.mobile.changePage( "#pageId", { transition: "slideup" });
    }
}, false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM