2

Javascript 文字列内で popover プラグインを機能させようとしています。したがって、ユーザーがマウスオーバーgeolocationするとポップオーバーが表示され、マウスを離すと消えます。

<script type="text/javascript">
     $('#directions-panel').text("We can't give you directions to our office as you don't have", <a href="#" rel="popover" data-content="Some content..." data-original-title="Some title..." > geolocation </a> " enabled on your browser. Enable geolocation and try again. The map above will show you where our office is located.");
</script>

そして、このようなものを使用して呼び出されますか??

$("[rel=popover]")
    .popover({
        offset: 10
    })
    .mouseover(function(e) {
        e.preventDefault()
    })

私はそれが少しあちこちにあることを知っていますが、私は周りを検索しましたが、私がやりたいことに似たものを見つけることができません. 私はそれができると確信しています、誰かが私を正しい方向に向けますか?

編集:

連絡先ページに次の情報があることを知っています。

<div id="directions-panel">
        <div id="directions-error-message" style="visibility:hidden">
          We can't give you directions to our office as you don't have <a href="#" id="geoloc-popover" rel="popover" data-content="Some content..." data-original-title="Some title..." > geolocation </a> enabled on your browser. Enable geolocation and try again. The map above will show you where our office is located.
        </div>
</div>

次の JSが起動すると、DIVdirections-error-messageが表示されます。function failure()

function failure() {
        alert("Your browser does not have geolocation enabled so we can't give you directions to our office. Enable geolocation and try again, or consult the map for our address.");
        $("#directions-error-message").css({
          visibility: 'visible'
        });     
        var destMapOptions = {
          zoom:15,
          mapTypeId: google.maps.MapTypeId.ROADMAP,
          center: new google.maps.LatLng(ourLocation.lat, ourLocation.lng)
        }
        map = new google.maps.Map(document.getElementById("map-canvas"), destMapOptions);
        marker = new google.maps.Marker({
          position: ourLatLng,
          map: map,
          draggable: false,
          animation: google.maps.Animation.DROP,
          title: "Hello"
        });
        google.maps.event.addListener(marker, 'click', toggleBounce);
    }


    $(function() {
        $('#directions-error-message').popover({
            selector: '[rel="popover"]', 
            trigger: 'hover'
        });
    })

directions-error-messageDIVの「地理位置情報」でポップオーバーをトリガーする方法はありますか?

4

2 に答える 2

1

代わりに次のようなものを試してみませんか:

<div style="visibility:hidden">
  We can't give you directions to our office as you don't have", <a href="#" rel="popover" data-content="Some content..." data-original-title="Some title..." > geolocation </a> " enabled on your browser. Enable geolocation and try again. The map above will show you where our office is located.
</div>

次に、javascriptを使用してdivの可視性を変更します。そうすれば、タイトルを設定するjQueryはリンクを認識しますが、ユーザーはあなたが望むまでリンクを見ることができません。

于 2012-09-05T11:55:15.077 に答える
1

Twitter Bootstrap の Popover プラグインには、data-api がポップオーバーの切り替えをトリガーできるようにするオプションがあります。これを有効にすると、適切なマークアップを使用して動的に追加されたすべての要素が、JavaScript でさらに初期化を呼び出さなくても機能します。

ほとんどの場合、ページ上のすべてのmouseenterおよびmouseleaveイベントをサブスクライブするとパフォーマンスの問題が発生する可能性があるため、この機能はデフォルトで無効になっています (TBS < 2.1 ではデフォルトです)。活性化された領域を比較的具体的に保つことができれば、パフォーマンスに関しては問題ないはずです.

#directions-panelホバーのみを有効にするには、構文は次のようになります。

$('#directions-panel').popover({selector: '[rel="popover"]', trigger: 'hover'});

ポップオーバーを含むパネルへの後続のすべての更新は、デフォルトでアクティブになります。

于 2012-09-05T19:09:47.267 に答える