2016-11-22 3 views
0

Es gibt zwei Schaltflächen "Button 1" für die Anzeige Popover und "Button 2" für eine externe Verbindung. einige maßgeschneiderte jquery für „Button 1“ zu hinzugefügt popover entlassen, wenn wir überall am Körper tippen, aber seine funktioniert nicht auf dem iPhone (es abtun nur, wenn Hahn auf der gleichen Taste in iphone)Bootstrap Popover Ablehnungsfunktion funktioniert nicht in iphone

$(document).ready(function() { 
 
     $("body").tooltip({ 
 
      selector: "a[data-toggle='tooltip']", 
 
      container: "body" 
 
     }) 
 
       .popover({ 
 
        selector: "a[data-toggle='popover']", 
 
        container: "body", 
 
        html: true 
 
       }); 
 
    }); 
 

 
    $('body').on('click', function (e) { 
 
     $('a[data-toggle="popover"]').each(function() { 
 
      if(!$(this).is(e.target) && 
 
        $(this).has(e.target).length === 0 && 
 
        $('.popover').has(e.target).length === 0) { 
 
       $(this).popover('hide'); 
 
      } 
 
     }); 
 
    });
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 

 
<div class="container" style="width:400px; height:400px; background:#000;padding-top:50px;"> 
 
    <a data-placement="top" role="button" class="btn btn-danger" data-toggle="popover" data-content="Popover" data-original-title="" title=""> Button1 </a> 
 
    <a class="btn btn-danger" href="http://facebook.com" target="_blank">Button2</a> </div>

Antwort

0

"Körper" Tag funktioniert nicht auf iphone, ich habe eine Klasse zu Körper hinzugefügt. Jetzt funktioniert es:

$(document).ready(function() { 
     $("body").tooltip({ 
      selector: "a[data-toggle='tooltip']", 
      container: "body" 
     }) 
       .popover({ 
        selector: "a[data-toggle='popover']", 
        container: "body", 
        html: true 
       }); 
    }); 

    $('.bodyClass').on('click', function (e) { 
     $('a[data-toggle="popover"]').each(function() { 
      if(!$(this).is(e.target) && 
        $(this).has(e.target).length === 0 && 
        $('.popover').has(e.target).length === 0) { 
       $(this).popover('hide'); 
      } 
     }); 
    }); 
Verwandte Themen