我正在尝试使用 popover 显示通知消息,它正在工作但是在加载页面后如果我第一次单击按钮它不会显示 popover 之后它工作正常这是我的代码 -
<button type="button" id="bulk_actions_btn" class="btn btn-default has-spinner-two" data-toggle="popover" data-placement="bottom" data-original-title="" data-content="Click any question mark icon to get help and tips with specific tasks"> Apply </button>
查询
$(document).on('click','#bulk_actions_btn',function(){
if(condition){
$('[data-toggle="popover"]').popover(); //here if the condition is true then popover should be display.
}else{
//ajax
}
});
原文由 user7160370 发布,翻译遵循 CC BY-SA 4.0 许可协议
你应该看看 popovers 方法:
为了显示您需要使用的弹出窗口:
而是使用:
选择器我建议你直接解决你的元素。
如果要使用数据属性来选择元素,则需要使用 过滤器 功能。
为了避免闪烁效果,您可以仅在隐藏时显示弹出窗口。如果您在按钮上点击得太快,您可以避免隐藏处理 hide.bs.popover 事件的弹出窗口。
片段: