开发者

jQuery: Freezing/Disabling all events temporarily?

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?


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


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.


You can use the modal dialog option built into JQuery UI

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

$("#dialog-modal").dialog({
                   modal: true
                   });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜