Understanding JavaScript and Page Transitions

Understanding JavaScript and Page Transitions

Hi,

I have been scratching my head for while trying to figure out how to get my pages to call the JavaScript initialisation just once and not repeatedly throughout the page transitions as pages are loaded and reloaded.

Initially I tried adding script section to my div data-role="content" section. Then I tried adding it to a section below and outside the  div data-role="page" section. Then I tried adding to an external JS file.

I'm tempted to remove the Ajax page loading, as some people have suggested, but that doesn't feel right either. I have created a couple of simplistic html files (attached as text files) that illustrate how many times the initialisation is being called, and how unpredictable it seems, to me at least.

My JS and JQM are a not too advanced, so I would be grateful for simple explanations.

Many thanks,



Kaine