How to refresh or reload a page in jquery mobile?

Page Reload/Refresh executes $(document).ready() on every page in jQuery Mobile

  • My jQuery mobile applications consists of multiple pages. Whenever I reload a page, no matter which page in the application, $(document).ready() function is executed. I expect it only to execute for the main page of the application. What is going on? I would like it only to run on the main page only.

  • Answer:

    Please read http://jquerymobile.com/demos/1.0/docs/api/events.html Important: Use pageInit(), not $(document).ready() The first thing you learn in jQuery is to call code inside the $(document).ready() function so everything will execute as soon as the DOM is loaded. However, in jQuery Mobile, Ajax is used to load the contents of each page into the DOM as you navigate, and the DOM ready handler only executes for the first page. To execute code whenever a new page is loaded and created, you can bind to the pageinit event. This event is explained in detail at the bottom of this page. Also for jQM page information please read http://jquerymobile.com/demos/1.0/docs/pages/index.html

user1107888 at Stack Overflow Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.