azicchetti / jquerymobile-router

A router/controller for jquery mobile. Also adds support for client-side parameters in the hash part of the url. The routes handles regexp based routes. This plugin can be used alone or (better) with Backbone.js or Spine.js, because it's originally meant to replace their router with something integrated with jQM.
GNU General Public License v2.0
402 stars 69 forks source link

Issue with jQM new popup widget and iFrame #61

Closed ghost closed 11 years ago

ghost commented 11 years ago

Over at jQm they recommend loading a Google map inside an iFrame to use with the new popup widget, see:

http://jquerymobile.com/demos/1.2.0/docs/pages/popup/popup-iframes.html

I have managed an implementation with Backbone and require, but have an issue when the popup closed in that I traverse back to a black page. Then I need to click the browsers back button but this brings me not to the view the popup was opened.

My guess would be that the history of the iFrame is in the way. If so, is there a way to prevent that?

From a smartphone you can access a live demo, go to:

www.yxyapp.com

click on "At your service" --> "Real Estate" and there on the first item in the list. In the next view click on "Deals" in the navigation bar. There swipe down and click on the "View on map" button and the map will popup. Tap anywhere beside the map to close it.

If you want to check from a computer please go to:

www.yxyapp.com/mobile/index.html

Hope that helps to track down the issue.

azicchetti commented 11 years ago

I think this issue is not related to the router because it can't do anything to "harm" pages or application layouts. Popups don't even trigger page events. The issue may reside in jquery mobile itself (but it's not likely) or in some event handler used in your code.

If you provide a tgz or a zip file of the source code, I'll try and see if the issue can be tracked down in a short amount of time.

Cheers, Andrea

azicchetti commented 11 years ago

It turns out I was wrong.

The router was forcing a useless changePage that, under normal circumstances, is harmless. In this specific case, jQuery Mobile was failing, probably due to a bug, during the page transition.

@bardu found out that the issue could be partially solved by disabling the slide effect.

However, I've patched the router to avoid the forced changePage when the popup is closed.

ghost commented 11 years ago

I have a new use case where I need to initialize and open a popup programmatically like:

$('#popupLogin').popup(); $('#popupLogin').popup('open');

Then I see the same issue as of before your patch, could you please check?

ghost commented 11 years ago

$('#popupLogin').popup({ history: false });

didn't help either.

azicchetti commented 11 years ago

Hi bardu, unfortunately the popup api and implementation seem way too inconsistent to build something on them. The .popup("open") call don't even trigger a pagebeforechange event, nor popup events. Writing a patch without these hook points is impossible.

I've noticed, however, that if you have a link such as:

<a href="#popupMap" id="mylink123" data-rel="popup">Open Popup</a>

Calling:

$("#mylink123").trigger("click");

produces the expected results (jQM fires the right events and the router can perform its task).

ghost commented 11 years ago

Hi Andrea,

I have tried your suggestion before, but it didn't work in my use case, and I run into more issues with the popup widget not related to routing.

I find the popup widget pretty useful, but as you said, it isn't mature enough to build something on it.

So, for now I will revert to a dialog widget for my latest use case and will see what jQM 1,2,1 has to offer regarding popup.

azicchetti commented 11 years ago

Il 18/10/2012 18:33, bardu ha scritto:

I find the popup widget pretty useful, but as you said, it isn't mature enough to build something on it.

So, for now I will revert to a dialog widget for my latest use case and will see what jQM 1,2,1 has to offer regarding popup.

If you don't mind, I'll email you a popup widget I've been using for the last year in my jQM projects. It's a small backbone view with a couple of methods, but you can easily revert it to a standard function if you want.

ghost commented 11 years ago

Much appreciated, I'm using backbone anyway!