使用
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”/>在popover上下文之外显示datepicker罚款.有任何想法吗?
解决方法
尝试使用回调扩展popover函数,因为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",html: true,callback: function() { $('.datepicker').datepicker(); } }).click(function (e) { e.preventDefault(); });
编辑:回调扩展解决方案从这里:Callback function after tooltip / popover is created with twitter bootstrap?
原文地址:https://www.jb51.cc/jquery/176911.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。