Ricki Ricardo
Posts: 0
Joined: Fri Nov 16, 2012 9:30 am

Popup window problem

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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Popup window problem

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.

Ricki Ricardo
Posts: 0
Joined: Fri Nov 16, 2012 9:30 am

Popup window problem

Thank you very very much. I guess problem fixed.

Return to “Issues”