Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5951377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:31:40+00:00 2026-05-22T17:31:40+00:00

I have a jquery mobile application with two pages. On the first page is

  • 0

I have a jquery mobile application with two “pages”. On the first page is a Google map, and on the second page is a listview of buildings, where each list item has an id associated with it. When the user clicks a building, the map is meant to pan to that building and show a marker. However, one of the quirks of jquery mobile is that I have to call google.maps.event.trigger(map, 'resize') and map.panTo(somePosition) after the page transition takes place, otherwise the map shows up funky. I am tapping into the jQuery Mobile pageshow event to do this. My question is, is there anything either in the pageshow event handler arguments or any way of attaching something to the pageshow event handler arguments that will allow me to identify the id of the list item that was clicked which caused the page transition in the first place, so I can use this to determine where to pan the map to?

At the moment, I’m having to do it in a round about kind of way, where I tap into the click event of the selected list item, store the selected list item id in a global variable and then use that global variable later on when in the pageshow event handler.

So something like:

var selectedBuilding;

$('a.buildingSelect').click(function(e) {
    e.preventDefault();
    selectedBuilding = $(this).attr("data-buildingNum");
});


$('div').live('pageshow',function(event, ui){
    if (ui.prevPage.attr('id') === "buildingSelect") {
        google.maps.event.trigger(map, 'resize');
        map.panTo(selectedBuilding);
    }
});

Apart from being a little messy, one of the problems with this is if the user didn’t select a building number at all, such as when they press the ‘back’ button on the building list page. In this case, the pageshow event handler still gets executed, though the selected building will be either non existent if the user hasn’t selected a building previously, or will cause the map to pan to the last selected building if they have selected a building previously, which isn’t actually the intended behaviour. I am sure I could make some additional global variables available to both event handlers to code around this, but it would be a little messy. Ideally what I’m looking for is a way to only have to bind to the pageshow event and from within the binded function be able to derive which building id was clicked.

I am still relatively new to jQuery and javascript in general, so please keep this in mind. Though I’ve had a bit of a play with the javascript debugging tools in Chrome, I’m still not really sure how I would go about effectively finding what information is made available in the ui argument to the pageshow event handler, which I imagine would be a good start towards solving problems like this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:31:41+00:00Added an answer on May 22, 2026 at 5:31 pm

    You could stick the pageshow event handler inside buildingSelect‘s click handler, and use the syntax that allows you to pass data through event binders: .live( eventType, eventData, handler ) from http://api.jquery.com/live/.

    But then you’d have to die the other live pageshow handlers before doing this. If it was me, I’d just clean up the way you’re storing those global variables and call it a day. Maybe put them in a nice object that sits off a namespace so it’s safer.

    EDIT: changed my incorrect colloquial “destroy” to the correct die. So you would want to die the event handlers as in $('div').die() or any of the other variations explained in the documentation: http://api.jquery.com/die/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a single page jQuery mobile application that consists of several list views
I have a single page jquery mobile application in which there are few parent
I have created a sample web application using jQuery Mobile. I have created two
I have a JQuery Mobile (1.0rc1) application that has a list view with a
i have created an application in jquery and google maps javascript v3 , in
I have a jquery-mobile application that is running inside a UIWebView in an iphone
I am using jquery mobile in iPhone application, I have included the resources files
I have a web application built with jQuery Mobile and PHP (CodeIgniter framework). Now
I have been assigned to build a mobile web application. I have found two
I have a Jquery Mobile controlgroup with two buttons: <div data-role=controlgroup data-type=horizontal class=headerMenu iconposSwitcher>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.