page logic work only from time to time

page logic work only from time to time

I have two cases.
First, the city is selected by clicking one of two buttons.
The value goes to localstorage.

The second case, a button "repeat order" was clicked.
Links with data from sqlite storage have the value "city".
They go to localstorage too, the debugger shows correct values.

The page logic works fine, price is according to city, but the displayed page is for the entire wrong city.
If I go back and click the link again - the same link - a correct page appears.

The logic sits in an pagebeforeshow event. I tried to do this in event handlers of the link clicking.
dot0 click function - saving city to localstorage - try to repeat the logic...

Need to hide a div and change displayed price of remained article.
It is a simple form app to gather order data and then send it.

I was happy to create the app, but the chief says, it forget the correct city from time to time.
Sorry for bad english.

I think humidiously, it is some kind of caching, and the pagebeforeshow event fires only at the second call - like an refresh. What can I use to do this logic? (the logic works, but the page is completely for an other city). The differences of pages are only the two, a div became hidden and a text string changes.
Note, background logic like the city value are there. Price is there too. But the correct page will display only after clicking the link a second time. Please help...