1

Wierd one here...

I am setting up my application, and I am loading in another page via the ajax method. Between these pages I have a simple forward/back method.

On the firing of the back method, I have placed a console log, and I can see that the first time i click back, it shows once, if i then go back into that page, and click back again, it then shows two, and so on.

This is resulting in wierd page reloading issues. (Clicking back and it transitions in the page I just clicked back from).

Using the data-rel="back", or a changePage method, the issue is the same.

I've had a google, and could not find anything.

Any help would be greatly appreciated.

Graeme Leighfield
  • 2,825
  • 3
  • 23
  • 38

1 Answers1

1

Your problem comes from multiple event binding. Because you didn't provide your code I cant tell you what specific line to change, but I can give you a link to my other answer.

There you will find multiple solutions with examples: jQuery Mobile: document ready vs page events. Just search for a topic: Prevent multiple event binding/triggering

In your case, some event is probably been applied each time a page is visited again. In case you are using jQuery Mobile page events and if it is possible for you an easiest solution would be to use a pageinit event.

Community
  • 1
  • 1
Gajotres
  • 57,309
  • 16
  • 102
  • 130
  • Ah, now that would make sense. Currently, I have a global scripts file with calls to pagecreate inside. What is a better solution? Individual scripts loaded in on each page? – Graeme Leighfield May 21 '13 at 23:20
  • I prefer individual scripts in each page but you will need to be careful even with this solution. Take a look at my other answer: http://stackoverflow.com/a/15806954/1848600 to find out why. Basically if you have several HTML files and you want to have a separate js files in each HTML, those js files will need to be placed in BODY. – Gajotres May 21 '13 at 23:23
  • OK Sounds great. My HTML files currently are just data-rel="page", there is no other content. Is this wrong? Or can i just put my JS file call inside the page content? – Graeme Leighfield May 21 '13 at 23:39
  • Had a look and your solution to kill the live() event sorted my issue. Your posts are very helpful - and I have bookmarked for future reference. Thanks for your assistance! – Graeme Leighfield May 22 '13 at 00:05