简体   繁体   English

打开另一个弹出窗口时关闭一个弹出窗口

[英]closing a popup when opening another popup

I have icons in my rich text area - icons for: link, insert image, insert column. 我的富文本区域中有图标-链接,插入图像,插入列的图标。 On each button when clicked it opens a popup which the user completes the task. 单击每个按钮时,都会打开一个弹出窗口,用户可以完成任务。 Each button functions like this went clicked: 每个按钮的功能如下:

onclick="$.Forms.WysiHtml5.InitEditor($(this));"

and when the click on the icon again it disappears: 当再次单击该图标时,它消失了:

onclick="$.Forms.WysiHtml5.ClosePopover($(this));"

Problem: 问题:
When i click a button and popup shows then i go click another button - another popup comes up leaving the page with two popups showing. 当我单击一个按钮并显示弹出窗口时,然后我单击另一个按钮-出现另一个弹出窗口,并在页面上显示两个弹出窗口。 I want it so that when i click on a button if there is a popup it will close and new popup for the clicked button will show. 我想要它,以便当我单击按钮时,如果有弹出窗口,它将关闭,并且将显示单击按钮的新弹出窗口。

Based on suggested answer below: 根据以下建议的答案:

'<a class="btn popover_btn" href="javascript:;" title="' + locale.css.columns.insert + '"'
                                    + 'data-placement="top" data-popover-selector="#RichText_ColsPopover"'
                                    + '$(#DynamicEditorForm)on("click", ".tool", function(){add close and open stuff}); tabindex="-1"><i class="icon-th"></i></a>'

Add a event delegation to the container: 将事件委托添加到容器中:

$("#container").on("click", ".tool", function(){
    // Close all
    // Open new one
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM