简体   繁体   English

如何在移动设备上的点击上禁用引导弹出窗口

[英]How to disable bootstrap popover on tap in mobile device

I am getting one major issue of bootstrap popover, it's working fine in desktop but not in mobile, When I tap on button which has pophover it's opening tooltip at first tap and firing event on second tap. 我遇到了一个主要问题,即启动弹出窗口,它在桌面环境下运行良好,但在移动设备上却无法正常工作,当我点击带有弹出窗口的按钮时,它在第一次点击时打开工具提示,而在第二次点击时触发事件。

In sort : bootstrap popover not firing event in one tap in mobile device, It's showing tool-tip instead. 排序:在移动设备中,轻按一次bootstrap popover不会触发事件,而是显示工具提示。

I want to get it disabled on mobile devices, or fire event with tooltip. 我想在移动设备上禁用它,或使用工具提示触发事件。

Let me show codes: 让我显示代码:

HTML HTML

<div class="container">
  <h3>Popover Example</h3>
  <a href="#" title="Header" data-toggle="popover" data-trigger="hover" data-content="Some content" class="">Hover over me</a>
</div>

JavaScript JavaScript的

$('[data-toggle="popover"]').popover();   
    $('[data-toggle="popover"]').click(function(){
        alert("I am clicked");
})

What I tried 我尝试了什么

var win = $(window).width();
   if(win<767) {
      $('[data-toggle="popover"]').removeAttr('data-toggle');
      // Or something like this disable popover
      $('[data-toggle="popover"]').popoverDisabled();
    }

So, Is there any function or attributes which can fix this, any help/suggestion would be appreciate. 因此,是否有任何功能或属性可以解决此问题,任何帮助/建议将不胜感激。

This will work: $('.className').popover('disable'); 这将起作用: $('.className').popover('disable');

Any for mobile only, for example: 仅适用于移动设备,例如:

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
        $('.className').popover('disable');
}

First Check Mobile Version run this function :- 首先检查手机版运行此功能:-

detectmob();
function detectmob() {
   if(window.innerWidth <= 800 && window.innerHeight <= 600) {
     $('[data-toggle="popover"]').popover("hide");
   } else {
     return false;
   }
}

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

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