Bootstrap jQuery 弹出框大小

4
在我的应用程序中,使用Bootstrap和FullCalendar时,弹出框的大小显示不正确。是否可以调整大小?我正在使用Bootstrap 3。 enter image description here
代码
$(window).load(function() { 
        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        /* initialize the external events
        -----------------------------------------------------------------*/

        $('#external-events div.external-event').each(function() {

            // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
            // it doesn't need to have a start or end
            var eventObject = {
                title: $.trim($(this).text()) // use the element's text as the event title
            };

            // store the Event Object in the DOM element so we can get to it later
            $(this).data('eventObject', eventObject);

            // make the event draggable using jQuery UI
            $(this).draggable({
                zIndex: 999,
                revert: true,      // will cause the event to go back to its
                revertDuration: 0  //  original position after the drag
            });

        });



        /* initialize the calendar
        -----------------------------------------------------------------*/

        $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            editable: true,
            droppable: true, // this allows things to be dropped onto the calendar !!!
            eventRender: function (event, element) {
                element.popover({
                    title: "My Title",
                    placement:'auto',
                    html:true,
                    trigger : 'click',
                    animation : 'true',
                    content: event.msg
                });
                $('body').on('click', function (e) {
                    if (!element.is(e.target) && element.has(e.target).length === 0 && $('.popover').has(e.target).length === 0)
                        element.popover('hide');
                });
              },

            events: [
                        {
                            title: 'All Day Event',
                            start: new Date(y, m, 1),
                            msg: 'I am OK',  
                        },
                        {
                            title: 'Long Event',
                            start: new Date(y, m, d-5),
                            end: new Date(y, m, d-2),
                            msg: 'I am double OK',  
                        },
                        {
                            id: 999,
                            title: 'Repeating Event',
                            start: new Date(y, m, d-3, 16, 0),
                            allDay: false
                        },
                        {
                            id: 999,
                            title: 'Repeating Event',
                            start: new Date(y, m, d+4, 16, 0),
                            allDay: false
                        },
                        {
                            title: 'Meeting',
                            start: new Date(y, m, d, 10, 30),
                            allDay: false
                        },
                        {
                            title: 'Lunch',
                            start: new Date(y, m, d, 12, 0),
                            end: new Date(y, m, d, 14, 0),
                            allDay: false
                        },
                        {
                            title: 'Birthday Party',
                            start: new Date(y, m, d+1, 19, 0),
                            end: new Date(y, m, d+1, 22, 30),
                            allDay: false
                        },
                        {
                            title: 'Click for Google',
                            start: new Date(y, m, 28),
                            end: new Date(y, m, 29),
                            url: 'http://google.com/'
                        }
                    ]       
        }); 

    });

JsFiddle http://jsfiddle.net/7gwz5/

2个回答

4

这个问题已经得到解决

只需在事件弹出框中添加{container:'body'},问题就会得到很好的解决。

element.popover({
                title: "My Title",
                placement:'auto',
                html:true,
                trigger : 'click',
                animation : 'true',
                content: event.msg,
                container:'body'
            });

更新了jslint http://jsfiddle.net/7gwz5/2/


0

我不知道与fullcalendar有什么不同,但是经典的Bootstrap popover结构看起来像这样:

<div class="popover">
    <h3 class="popover-title">Title</h3>
    <div class="popover-content">Content</div>
</div>

然后你只需要设置 .popover 类的大小,它应该可以工作;还要验证你的 JavaScript 插件是否会改变大小或更改类(例如使用 Google Chrome 的开发者工具)。 如果仍然无法正常工作,请发布一个包含你的代码的 fiddle,我们可以轻松地进行调试。;)


请查看包含 width 值的弹出框更新后的 jsfiddle:http://jsfiddle.net/7gwz5/1/ - Jérémy Dutheil
CSS技巧。谢谢您的回复,但弹出窗口仍然显示在完整日历区域下面。是否可能查看外部? - Anish
感谢 @Jeremy Dutheil - Anish
你使用的是哪个浏览器?在最新版的Chrome中,弹出窗口会显示在上方。 - Jérémy Dutheil
无论是在chrome(29.0)还是firefox(23.0)上都是这样显示的,不管怎样还是非常感谢你的帮助:) - Anish
@JérémyDutheil 如果我的事件在单独的JSON文件中,我该如何实现相同的功能?你能否在JSFiddle上向我展示一个演示? - arjun

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接