>我发现样本几乎像我的一样,如果我单击屏幕上弹出框会隐藏的任何地方,我需要它。可能吗?如果是,如何?
$.fn.popover.defaults.container = 'body';
$('#mycalendar').fullCalendar(
{
defaultView: "agendaWeek",
slotMinutes:60,
allDaySlot:false,
header: {
left: 'prev,next today',
center: 'title',
right: 'agendaWeek,agendaDay'
},
eventRender: function (event, element) {
element.popover({
title: "My Title",
placement: event.start.getHours()>12?'top':'bottom',
html:true,
content: event.msg
});
},
editable: false,
events: [
{
title : 'Click me 3',
msg: 'I am clipped to the right which is annoying',
start : '2011-05-07 12:00:00',
end : '2011-05-07 13:00:00',
editable: false,
allDay : false
}
]
});
$('#mycalendar').fullCalendar( 'gotoDate', 2011,04,7 );
JSFIDDLE可以在这里找到。
我将不胜感激的任何帮助
在事件呈现函数中尝试以下更改:
eventRender: function (event, element) {
element.popover({
title: "My Title",
placement: event.start.getHours()>12?'top':'bottom',
html:true,
content: event.msg,
trigger: 'focus' // trigger popover on element focus
});
element.attr('tabindex', -1); // make the element (div) focusable
},
我还在这里更新了 jsfiddle。
只需在脚本中添加此 J 查询代码:
$(document).on('click', function (e) {
$('[data-toggle="popover"],[data-original-title]').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
(($(this).popover('hide').data('bs.popover') || {}).inState || {}).click = false // fix for BS 3.3.6
}
});
});
注意:它将关闭以前的弹出窗口。