简体   繁体   English

按钮单击在引导程序弹出窗口内无法正常工作

[英]button click does not work properly inside bootstrap popover

Here is my popover element: 这是我的popover元素:

<a data-placement="bottom" data-toggle="popover" data-trigger="focus" tabindex="1"></a>

My bootstrap popover content is a social media button. 我的引导弹出式窗口内容是社交媒体按钮。 It shares something when you click on it. 当您单击它时,它共享一些东西。 However, click event is not triggered properly. 但是,单击事件未正确触发。 When I click share button which is available when popover is displayed, it fails one or two times out of 3 clicks. 当我单击显示弹出窗口时可用的共享按钮时,它在3次单击中失败一两次。

var options =  {};
options.content = function() {
      return "<ul class='social social-list'>" +
               "<li><a id='fa-facebook' class='social-fb'><i class='fa fa-facebook fa-lg'></i></a></li>" +
             "</ul>"; 
      };

options.trigger = 'focus';     
options.html = true;

$('[data-toggle="popover"]').popover(options).on('shown.bs.popover', function(){

   var fbShareEvent = $("#fa-facebook").data("events");
   if(!fbShareEvent){
     $("#fa-facebook").on("click",function(event){
         fbShare();
     });
   }
}

After spending half day, I found solution. 度过了半天后,我找到了解决方案。 Since popover hide action triggered by focus event, sometimes popover is closed before click action is triggered. 由于弹出窗口隐藏动作是由焦点事件触发的,因此有时会在单击动作触发之前关闭弹出窗口。 I added delay parameter to my popover options. 我在我的弹出框选项中添加了delay参数。

options.delay = {'hide': 500};

This parameter delays close action for a given amount of time. 此参数将关闭动作延迟给定的时间。 Thus, click action can be handled before the popover is closed. 因此,可以在关闭弹出窗口之前处理单击动作。

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

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