jQuery.mobile popup immediately hides after showing

I have a small phonegap application with jquery mobile and backbone.
I’m trying to show popup to user by manually calling .popup() method.

Everything works fine on iOS but on android I got strange issue: popup is showing for few moments and than disappear.

  • Android SQLite Cursor out of bounds exception on SELECT count(*) FROM table
  • Fake Poor Internet
  • how to fire an event when someone clicks anywhere on the screen in an android app?
  • How to analyze an Android /data/anr/traces.txt file?
  • Different text size for different hardware
  • How to auto import the necessary classes in Android Studio with shortcut?
  • Here the actual code:

    var PostView = Backbone.View.extend({
      events: {
        'touchend .add-comment-button': 'addComment'
      addComment: function() {
        this.$(".comment-popup").popup('open', { history: false });
        return false; // Stop bubbling.

    I’m using history: false because this popup is actualy part of subpage.
    The code looks very simple, I’m just can’t understand why it can disappear, and why this happen only on android devices.

    Thanks, and sorry for my bad english.

    Related posts:

    Android: how to use dip (density independent pixel) in code?
    JAVAH can't find class( android ndk)
    How to Display AChartEngine bar chart properly
    Calling startActivity() from outside of an Activity context
    How to implement zoom effect for image view in android?
    Broadcast Receiver Not Working After Device Reboot in Android
  • How to keep onItemSelected from firing off on a newly instantiated Spinner?
  • Android canvas: draw transparent circle on image
  • How to Get EditText maxLength setting in code
  • Android alphabetical fast scrollview in RecyclerView with Collapsing toolbar
  • Android Support Library ActionBar not Working in 2.3 Device
  • Gradle script to autoversion and include the commit hash in Android
  • 7 Solutions collect form web for “jQuery.mobile popup immediately hides after showing”

    I spent hours trying to fix this problem.

    Finally I ended up doing the following two things that seemed to fix the problem.

    1 – Use the uncompressed jqm file. i.e jquery.mobile.1.2.0.js

    2 – I was triggering the popup programatically using the ‘tap’ option – once changed to the ‘click’ option it worked.

    $('.option').live('click', function() {

    I spent hours trying to fix this problem.

    Finally I ended up doing the following two things that seemed to fix the problem.

    this code snippet may help you ->

       console.log("button clicked");

    Please note i have used e.perventDefault().

    I didn’t feel like changing my .tap() events to the click event and I didn’t have a case where I could use preventDefault()so I just added a timeout to the popup(‘open’) line. My hoverdelay in jqm is set to 150 so I set this timeout to 600 just to be on the safe side. Works fine, doesn’t feel sluggish for the user.

    One way to ‘fix’ it is by setting data-history="false" on the popup div

    See also this question

    JQuery Mobile popup with history=false autocloses

    I have the exact same problem when trying to use popup(‘open’) on an android 2.3 device (both in native browser and in firefox) and it works just fine on browsers on other devices. I’m also using backbone event management to open my popup (used the tap event and no aditionnal options to popup).

    What I did to ‘correct’ the problem is that I removed the backbone event management for this event and added a listener in the render function. In your case this would look something like this :

        events: {
           // 'touchend .add-comment-button': 'addComment'
        render: function() {
                    return false;

    I have no idea where the problem comes from (must be some incompatibility between backbone and jquery mobile) and why we only see it on android but for the moment with this workaround my app seems to work fine on any device.

    Edit: oops, it turns out that in my case the problem was I was missing “return false;” in the function dealing with the event.
    Now that I added it, it works correctly with the backbone event management.
    Sadly that doesn’t explain why you have the issue and why I was seeing it only on android.

    In case it helps anyone, I had the same problem occurring with Bing Maps, with the Microsoft.Maps.Events.addHandler(pin, 'click', callback) method.

    Not particularly nice, but instead I stored an ID in pushpin._id and did the following:

    $("#page").on('vclick', function (event) {
        if (event.target.parentElement.className === "MapPushpinBase") {

    One brute force option is to check whether popup was hidden and reopen it.

    In a loop, because the exact time the popup becomes hidden seems to be varied.

    var hidden = $('#' + id + '-popup') .hasClass ('ui-popup-hidden')
    if (hidden) $('#' + id) .popup ('open')

    A working example: http://jsfiddle.net/ArtemGr/hgbdv9s7/

    Another option could be to bind to popupafterclose:

    var reopener = function() {$('#' + id) .popup ('open')}
    $('#' + id) .on ('popupafterclose', reopener)
    $('#' + id) .popup ('open')

    Like here: http://jsfiddle.net/ArtemGr/gmpczrdm/

    But for some reason the popupafterclose binding fails to fire on iPhone 4 half of the time.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.