I have a multi page template in jQuery Mobile. How can I refresh the current page when clicking on a hyperlink or button? I am using JQM version 1.4.5
Despite trying the code suggested in how to refresh(reload) page when click button in jQuery Mobile, it is not working as expected:
// Refresh the store main page - experimental
$(document).on('click', '#aStoreReload', function (event) {
$.mobile.changePage(window.location.href, {
allowSamePageTransition: true,
transition: 'none',
showLoadMsg: false,
reload: true // also tried reloadPage: true
});
});
It is returning to the main page with the URL unchanged, such as
http://localhost:56235/main.html#storeMainPage
on the local server. However, JsBin displays a blank page while JSFiddle does nothing. Click on the store link to see the page with the refresh button.
What would be the proper way to refresh the page (view)?
Edit
I also attempted the following scripts on the click event:
$.mobile.changePage($("#storeMainPage"), { transition: 'slidedown' });
$(document).pagecontainer("load", "#storeMainPage", { reload: true });
The first line has no effect and the second line throws an error
Uncaught Error: cannot call methods on pagecontainer prior to initialization; attempted to call method 'load'
, which is expected as we are calling pagecontainer before its initialization.