2

Possible Duplicate:
jQuery mobile $(document).ready equivalent
Does ready event fire when page-turn

I Have two pages - Page1.html And Page2.html.
I am calling Page2.html from Page1.html.
In that scenario, $(document).ready is not firing in Page2.html.

Code I used to navigate is:

<li><a href="Page2.html" data-prefetch="true" data-transition="flip">Page 2</a></li>
Community
  • 1
  • 1
  • 1
    The answer I gave there, the ready event fire only once. Read it all there, no need to create a duplicate question and answers. – gdoron Jun 25 '12 at 23:03

1 Answers1

1

see this http://jquerymobile.com/test/docs/api/events.html

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.

Parv Sharma
  • 12,581
  • 4
  • 48
  • 80
  • I don't want to sound rude, but it looks like you just copied it from the duplicate question. Why? – gdoron Jun 25 '12 at 23:13
  • 2
    He linked to the question And posted the relevant section inline. To me that's a perfect response – rooftop Jun 25 '12 at 23:21
  • @rooftop. No he linked to the source of the answer. anyway, I just don't the why should one do that. never mind. – gdoron Jun 25 '12 at 23:43
  • @gdoron, One can not assume your answer was visited by the creator of this answer. It's a coincidence the source of your answer and this answer points to the same jQuery Mobile API excerpt. I too was about to post a similar answer from my own experience with jQuery Mobile without looking at your answer. Also, note the last two words `pageinit event` of your answer is not in bold while they are shown in bold here and this answer is in italics while yours is not. IMHO, this answer is not a copied version of your answer. Opps, disregard everything I just wrote since I was told to never mind. :-p – arttronics Jun 26 '12 at 00:56
  • @arttronics. :) I just don't like duplicate for no good reason. – gdoron Jun 26 '12 at 07:45
  • @gdoron - when i looked at the ques i wasnt aware that there is a duplicate question. when i answered and read the comments i found out one.. so inspite to this ans i flagged the ques as a duplicate.. – Parv Sharma Jun 26 '12 at 08:42