Page 1 of 1

Popup window problem

Posted: Thu Apr 04, 2013 10:47 am
by Ricki Ricardo

I have application with custom design. I use some popup window on it. I add event to popup and they open normal, but I have a problem. I open 1-st popup and close it - all normal. Then I open 2-nd popup and close, all good. I open 1-st popup and close, 1-st popup open one time. I close it and open 2-nd popup and close. 2-nd popup opens 2 times, 1st - opens 3 time, etc.

This my code to open popup.

$(namespace + '.comment-btn').live('click', function() {
$.mobile.changePage('omniTracker_commentPopup.html', {transition: 'pop'});
});

$(namespace + 'ul.activity-info li.comments').live('click', function() {
$.mobile.changePage('omniTracker_commentPopup.html', {transition: 'pop'});
});

$(namespace + '.acknowledge-btn').live('click', function() {
$.mobile.changePage('omniTracker_acknowledgePopup.html', {transition: 'pop'});
});

$(namespace + '#add-message-btn').live('click', function() {
$.mobile.changePage('omniTracker_newMessagePopup.html', {transition: 'pop'});
});

This link to reproduce this bug.
https://www.youtube.com/watch?v=Gk4Mvm...

Could you help me with it?
Thank you for advice.


Popup window problem

Posted: Thu Apr 04, 2013 2:07 pm
by Kateryna Grynko

Hi,

Sorry for the delay.
Ass I can see the code is run several times (each time page loads or another event) and handler is added several times.

You can try another way to add click event handler.

Also, you use method "live" that is deprecated
http://api.jquery.com/live/

Maybe you would change it to "delegate" or "on" method.


Popup window problem

Posted: Fri Apr 05, 2013 9:05 am
by Ricki Ricardo

Thank you very very much. I guess problem fixed.