2013-03-22 7 views
6

प्रदर्शित नहीं करेगा Twitter Bootstrap और Bootstrap-datepicker एक्सटेंशन का उपयोग करना। मैं popover के अंदर डेटपिकर डिस्प्ले नहीं कर पा रहा हूं।पॉपओवर में डेटपिकर

<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" /> पॉपओवर संदर्भ के बाहर datepicker ठीक प्रदर्शित करता है। कोई विचार?

उत्तर

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(); 
}); 

संपादित Callback function after tooltip/popover is created with twitter bootstrap?

+0

वाह निर्दोष जीत! धन्यवाद कि सही काम किया। – mxmissile

+3

आप ईवेंट 'show.bs.popover' के लिए भी सुन सकते हैं –

+1

@naturalethic के लिए धन्यवाद मैंने यह भी पाया कि 'inserted.bs.popover' ईवेंट का उपयोग करके बेहतर काम करता है क्योंकि यह पॉपओवर की स्थिति के साथ अच्छी तरह से खेलता है। जैसे ही पॉपओवर टेम्पलेट को डोम में जोड़ा जाता है, इसे जल्द ही कहा जाता है – katwekibs

संबंधित मुद्दे