I’m working on a mobile website with jQuery Mobile. I know the framework puts pages in cache so that it can make nice transitions between pages, reduce data transfer and so on.
But in my case it’s pretty boring because I think it doesn’t execute some JavaScript in my page. I’ll explain:
this page presents a form with a date field. I use mobiscroll to make a date-picker appear when the focus is on that field.
When I submit the form, if there’s a validation error (I use codeigniter), the server redirects to the form (repopulates the fields etc..) and then the date-picker doesn’t work anymore. If I initiate it from the JS console it works again so that’s make me think the JS code didn’t be re-executed when coming back to the form page.
I added data-ajax="false" as attribute of the form to make it work (I lost the pretty transition but I don’t really care). Is that the best solution ?
Then I looked for another way to do it definitively because the cache mechanism makes problems in other pages. So I found:
$(document).live("mobileinit", function() {
$.mobile.ajaxLinksEnabled = false;
});
This should be completely deactivating the cache but it’s not the case. I tried to remove some data-ajax="false" and then I had the same problem as before.
So what’s the matter with the page caching mechanism? And why doesn’t $.mobile.ajaxLinksEnabled = false; work?
Thanks!
I could get the
working and for my problem it was better to do
I wasn’t loading the .js files in the right order. (see the mobileinit event http://jquerymobile.com/demos/1.0/docs/api/globalconfig.html)
BUT I’m still wondering why my script wasn’t executed after each page load (or whatever for the ajax navigation system).