0

I have my JQM application, in my page I loading datas from external JSON for show markers in my Google Map.

I use this page structure:

// GOOGLE MAPS RICERCA 
$(document).on('pageshow','#map3', function(){
//show map in my page
});

When I click a marker, I show a new page with details. If I click "back" button, I return on the #map3 page, and reload again the datas and the map.

I'd like that the map refreshed only with the pression of apposite button in a map page (and not every time).

Can you help me?

Henry8
  • 266
  • 3
  • 8
  • 25

2 Answers2

1

Generally, no. It's not possible to stop reload a page. If user wants reload a page it will reloading by client and request to server to reloading.

You can send an javascript event to ask user want to reload page or not.

Instead this you can make to user ask about reloading a page and continue on page:

<script type="text/javascript">
    window.onbeforeunload = function() {
        return "Do you want to leave a page?";
    }
</script>
Marin Sagovac
  • 3,932
  • 5
  • 23
  • 53
  • I can't choose it? Is a big problem... because in this case, every time that the user come back to the map page, the map is reloaded completely. (same JSON from web service). – Henry8 Jul 29 '13 at 14:34
  • 1
    Try to ask on google group on google maps subforums, maybe would some answer properly for your question. – Marin Sagovac Jul 30 '13 at 07:43
1

What about using pageinit event instead of pageshow? I hope I understand correctly, you want to load it when the page is created and navigated into, but you don't want to load it when you get back to the same page. The "back" button should be either browser's back button, or jQuery mobile back button (<a data-rel="back">Back</a>) If this is what you want, I would try this:

$(document).on('pageinit','#map3', function(){
    //show map in my page
});

There is a nice explanation of various page and non page events in jQuery Mobile here:

jQuery Mobile: document ready vs page events

Community
  • 1
  • 1
mara-mfa
  • 895
  • 6
  • 9
  • Thank for your answer; using "pageinit" I had a problems with the Google Maps canvans... doesn't load correctly in my page. – Henry8 Jul 29 '13 at 16:20