I'm trying to do a very simple thing with JQM, but I'm having issues doing it (I'm a newbie to JQM, sorry).
I have a main page that link to a secondary page. In this secondary page I would like to load a dynamic content inside a div (#main). The first problem was binding to the pageshow event, because sometimes it would not fire or it would fire more than one time. I have fixed that issue using the .one function and moving the script inside the page DIV.
The first time I visit the page I can see the alerts and the content is change accordingly. The second time I visit this page (return home and the return to the page) I see the alerts but I don't see the content. The content remains unchanged (empty).
It's doing exactly what you asked - firing the pageshow event once - the first first time the page is shown. If the user navigates away and then immediately back, it will not fire again, because you use .one().
It will fire again - once - if the page is re-loaded. The page is reloaded if it is removed form the DOM and then the user navigates to it. Unless you cache it (data-dom-cache="true") it will be removed once the user navigates away from it, and then navigates away from the new page.
Since you didn't post your original code, we can't tell what is wrong with it. It's more useful to post your code that doesn't work as expected than it is to post your fix that also doesn't work as expected. Let's find out where you went wrong in the first place.
If you want to do something when the page is loaded, use a pageinit event.
If you want to do something every time the page is shown, use a pagebeforeshow event.
I have used the .one function because, if I used .bind the function will be called more than one time, becauase I imagine I am attaching the same function many times to the same event. Anyway, below I have attached the original page. As you can see, the pagebeforeshow is called every time I enter in the page. The problem is that the first time the DOM is updated with the content that I load with AJAX, but next times, even if the AJAX request is executed correctly, the DOM is not changed anymore. The #main div remains empty, and I can't understand why.