New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

popup window closes automatically when initiated via javascript #8045

Closed
rhysryan opened this Issue Mar 26, 2015 · 10 comments

Comments

Projects
None yet
6 participants
@rhysryan

rhysryan commented Mar 26, 2015

I have noticed that in my Safari on a MAC, a pop-up window automatically closes when it is opened via JavaScript. All seems to work well in Chrome and Firefox. This is related to issue #5794.

Here's my environment:

  • MAC Yosemite 10.10.2
  • Safari 8.0.4
  • jQuery 2.1.3
  • jQuery Mobile 1.4.5

Here's the JavaScript to open the popup:
$("#refreshPopup").popup( "open" );

Here's the main line of the popup itself:
<div data-role="popup" id="refreshPopup" data-overlay-theme="b" data-theme="b" data-dismissible="true" data-history="false" style="max-width:400px;">

To get around the problem,in jquery.mobile.1.4.5.js, I commented out line 11137:
self._bindContainerClose();

I really hate to do this but I couldn't go back to 1.3.2, which seems to be the last version that this issue was fixed. I tested this on my MAC with Firefox, Safari and Chrome and no more problems. I also tested on Safari on IOS 8 and Android with Chrome without any issues. I also tested on Windows 8.1 with the newest version of IE, Safari, Chrome and Firefox and the fix seemed to work. I know I probably broke something else but I really needed this to work.

@gabrielschulhof

This comment has been minimized.

Show comment
Hide comment
@gabrielschulhof

gabrielschulhof Mar 26, 2015

Contributor

@rhysryan if you're opening the popup from a click handler, you must prevent default on the click event. Can you modify our template to create a test case illustrating the problem?

Contributor

gabrielschulhof commented Mar 26, 2015

@rhysryan if you're opening the popup from a click handler, you must prevent default on the click event. Can you modify our template to create a test case illustrating the problem?

@rhysryan

This comment has been minimized.

Show comment
Hide comment
@rhysryan

rhysryan Mar 26, 2015

@gabrielschulhof

No, I am not using a click handler. In my pageshow function I am just
calling the open method.

Thanks.

gabrielschulhof wrote:

@rhysryan https://github.com/rhysryan if you're opening the popup
from a click handler, you must prevent default on the click event. Can
you modify our template http://jsbin.com/huvoraba/1 to create a test
case illustrating the problem?


Reply to this email directly or view it on GitHub
#8045 (comment).

rhysryan commented Mar 26, 2015

@gabrielschulhof

No, I am not using a click handler. In my pageshow function I am just
calling the open method.

Thanks.

gabrielschulhof wrote:

@rhysryan https://github.com/rhysryan if you're opening the popup
from a click handler, you must prevent default on the click event. Can
you modify our template http://jsbin.com/huvoraba/1 to create a test
case illustrating the problem?


Reply to this email directly or view it on GitHub
#8045 (comment).

@kapilgarg1996

This comment has been minimized.

Show comment
Hide comment
@kapilgarg1996

kapilgarg1996 Mar 26, 2015

Contributor

@rhysryan The issue you referenced provides a demo http://jsbin.com/onuduw/5/edit
Are you trying to do the same..?

Contributor

kapilgarg1996 commented Mar 26, 2015

@rhysryan The issue you referenced provides a demo http://jsbin.com/onuduw/5/edit
Are you trying to do the same..?

@rhysryan

This comment has been minimized.

Show comment
Hide comment
@rhysryan

rhysryan Mar 26, 2015

@kapilgarg1996 Yes, basically the same. I even took that exact code of that demo, which worked with 1.3.2, and pointed it to 1.4.5. The result was that the popup no longer worked.

rhysryan commented Mar 26, 2015

@kapilgarg1996 Yes, basically the same. I even took that exact code of that demo, which worked with 1.3.2, and pointed it to 1.4.5. The result was that the popup no longer worked.

@gabrielschulhof

This comment has been minimized.

Show comment
Hide comment
@gabrielschulhof

gabrielschulhof Mar 26, 2015

Contributor

Yeah, there's a spurious navigate event which closes the popup. This used to be a problem in Chrome too, but it seems it got fixed. Not so in Safari.

Contributor

gabrielschulhof commented Mar 26, 2015

Yeah, there's a spurious navigate event which closes the popup. This used to be a problem in Chrome too, but it seems it got fixed. Not so in Safari.

@kapilgarg1996

This comment has been minimized.

Show comment
Hide comment
@kapilgarg1996

kapilgarg1996 Mar 26, 2015

Contributor

@gabrielschulhof I don't think it has been fixed in chrome.
http://jsbin.com/rifuha/1/edit

Contributor

kapilgarg1996 commented Mar 26, 2015

@gabrielschulhof I don't think it has been fixed in chrome.
http://jsbin.com/rifuha/1/edit

@gabrielschulhof

This comment has been minimized.

Show comment
Hide comment
@gabrielschulhof

gabrielschulhof Mar 26, 2015

Contributor

@kapilgarg1996 It has been. You must define the mobileinit handler before you refer to jQuery Mobile via a script tag, because mobileinit is fired from one of mobile's outermost IIFEs: http://jsbin.com/vohozu/1/

Contributor

gabrielschulhof commented Mar 26, 2015

@kapilgarg1996 It has been. You must define the mobileinit handler before you refer to jQuery Mobile via a script tag, because mobileinit is fired from one of mobile's outermost IIFEs: http://jsbin.com/vohozu/1/

@Moinkhaan

This comment has been minimized.

Show comment
Hide comment
@Moinkhaan

Moinkhaan May 13, 2015

I was calling 'open' method within a function and this function was being called by click event. Applying preventDefault() on that click event fixed the issue for me. (and the issue was only seen in android 4.3 default stock browser, not chrome, not even default stock browsers of any other android version).

Thank you @gabrielschulhof

Moinkhaan commented May 13, 2015

I was calling 'open' method within a function and this function was being called by click event. Applying preventDefault() on that click event fixed the issue for me. (and the issue was only seen in android 4.3 default stock browser, not chrome, not even default stock browsers of any other android version).

Thank you @gabrielschulhof

@chaintng

This comment has been minimized.

Show comment
Hide comment
@chaintng

chaintng May 29, 2015

I also have this problem too. Is there anyway to fix this problem yet?

Workaround by comment this line
self._bindContainerClose(); does work in safari but not in iphone.

chaintng commented May 29, 2015

I also have this problem too. Is there anyway to fix this problem yet?

Workaround by comment this line
self._bindContainerClose(); does work in safari but not in iphone.

@arschmitz

This comment has been minimized.

Show comment
Hide comment
@arschmitz

arschmitz May 29, 2015

Member

@chaintan17 this is already fixed on master thats why its closed.

Member

arschmitz commented May 29, 2015

@chaintan17 this is already fixed on master thats why its closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment