views:

34

answers:

3

I have the following usecase:

  • A div with some buttons
  • When the user clicks on a button, a popup is shown and the background div is faded out to 0.5 opacity

The problem is that when the popup comes in, the user is still able to click on the background buttons. At this point, I can remove the entire DIV temporarily but I don't want to do that. Is there anyway I can disable all the previously attached events and then add event handlers ONLY to the current popup? (I mean something like a close button should still work on a popup) Any suggestions?

+1  A: 

Sounds like you need a modal popup. There are numerous jQuery plugins that do that, or you can check out this tutorial.

Robert Harvey
+1  A: 

You could store each element with an attached event into an array, then loop through them and unbind() them. Upon closing the popup you can re-bind() them.

Calvin L
+1 for this. I tried this approach but somehow thought it could end up being heavy.
Legend
+1  A: 

You can use the modal dialog option built into JQuery UI

http://jqueryui.com/demos/dialog/#modal

$("#dialog-modal").dialog({
                   modal: true
                   });
orandov
+1 for the suggestion. Thanks...
Legend