7

TwitterBootstrapとBootstrap -datepicker拡張機能を使用します。ポップオーバー内に日付ピッカーを表示できません。

<a href="#" id="add-event-button" class="btn btn-small">Add an Event</a>

$(document).ready(function () {

    $("#add-event-button").popover({
        title: "Add an Event",
        placement: 'bottom',
        content: '<input class="datepicker" type="text" />',
        html: true
    }).click(function (e) {
        e.preventDefault();
    });
});

ポップオーバーは問題なく表示<input class="datepicker" type="text" />され、ポップオーバーコンテキストの外側では日付ピッカーが問題なく表示されます。何か案は?

4

1 に答える 1

14

コールバックを使用してポップオーバー関数を拡張してみてください。ロード時にdatepickerを存在しない要素に追加できないため、次のことを試してください。

var tmp = $.fn.popover.Constructor.prototype.show;
$.fn.popover.Constructor.prototype.show = function () {
  tmp.call(this);
  if (this.options.callback) {
    this.options.callback();
  }
}

$("#add-event-button").popover({ 
  title: "Add an Event",
  placement: 'bottom',
  content: '<input class="datepicker" type="text" />',
  html: true, 
  callback: function() { 
    $('.datepicker').datepicker(); 
  }
}).click(function (e) {
  e.preventDefault();
});

編集:ここからのコールバック拡張ソリューション:ツールチップ/ポップオーバーがTwitterブートストラップで作成された後のコールバック関数?

于 2013-03-22T18:43:28.257 に答える