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
Related Q & A:
- How to execute ajax script on Jquery mobile?Best solution by Stack Overflow
- How to open a partial view from controller as a Jquery Mobile dialog?Best solution by Stack Overflow
- how to submit form using jquery mobile?Best solution by Stack Overflow
- How to refresh jQuery mobile page?Best solution by Stack Overflow
- Why is the entire top of the page cut off on the new "My Yahoo" page?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.