Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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.

like image 463
Dmitry Chirkin Avatar asked Oct 10 '12 12:10

Dmitry Chirkin


1 Answers

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() {
    $('#popup-div').popup('open');
}); 
like image 124
someuser Avatar answered Oct 12 '22 21:10

someuser