Phương Nguyễn
Phương Nguyễn

Reputation: 8905

jQuery Mobile is not reloading my page properly

Ok, this is odd: First I open page1.html. From page1.html I go to page2.html by link and then back to page1.html via another link. These links are just regular links with relative path and not rel="back" kind of link.

Problem is: jQuery Mobile will cache page1.html (though it doesn't cache page2.html) If I add rel="external" to the link of page2.html then the page1 is refresh, but together, all resources is also reloaded (which not what I want).

I only want the html of page1.html to be reloaded. I added data-cache=false and data-dom-cache=false to page1.html annotation but it doesn't help.

How can I have jQuery Mobile not caching page1.html with the given scenario?

Upvotes: 1

Views: 409

Answers (1)

seberenimer
seberenimer

Reputation: 123

I am using a workarround that manualy removes the page based on the data-dom-cache attribute. You need to add an event handler for pagehide events and check for the domCache property of the page data

$(document).on('pagehide', function(event, ui){
          var page = $(event.target);
          var pageData = page.data(); // get all the data attributes (remove the data prefix and format to camel case)
          if(pageData.domCache == false){
              console.log("Removing Page (id: " + page.attr('id') + ", url: " + pageData.url + ")"); //Log to console for debugging
              page.remove(); // remove the page
        }
    });

Upvotes: 1

Related Questions