【问题标题】:Fullcalendar with Twitter Bootstrap Popover带有 Twitter Bootstrap 弹出框的完整日历
【发布时间】:2012-12-18 22:48:47
【问题描述】:

我正在尝试让 Fullcalendar 与 twitter boostrap popovers 一起使用。
如果我单击一个事件,我想在弹出窗口中显示一些详细信息。
所以首先将这个 lil sn-p 添加到 Fullcalendar:

eventClick: function(event, jsEvent, view) {
        $this = $(this);
        $this.popover({html:true,title:event.title,placement:'top'}).popover('show');
        return false;            
    },

但现在我遇到了两个问题:

  1. Fullcalendar 位于具有溢出:隐藏或其他内容的 div 中,因为弹出框在 Fullcalendar 的边界上被剪切。我该如何解决?
  2. 类似于问题 2 我想通过函数将弹出框放置在顶部、左侧、右侧或底部,具体取决于事件在 Fullcalendar 网格中的位置。我怎么能做这样的功能?

谢谢!

【问题讨论】:

  • 如果你能提供小提琴或页面链接会很棒。
  • 对于第 2 点)我现在实施了一个次优解决方案,即如果事件发生在周日到周三,我将弹出框放在右侧,否则放在左侧。如果view.type 是Day 或agendaDay,我将它放在最上面。这样,您通常可以防止弹出框被任何东西遮挡。

标签: twitter-bootstrap fullcalendar popover


【解决方案1】:

几天;

        dayClick: function (date, jsEvent, view) {
            //return eventCreate(date, null, jsEvent, view);
            var CurrentDay = $(this);

            CurrentDay.popover({
                html: true,
                placement: 'auto',
                title: date.format(),
                container:'#calendar',
                content: function() {
                    setTimeout(function () {
                        CurrentDay.popover('hide');
                    }, 2000);
                    return $("#popover-day").html();
                }
            });
            CurrentDay.popover('toggle');
    },

对于事件;

        eventRender: function (event, element, view){
        var dStart = event.title
        element.popover({
            animation: true,
            placement: 'top',
            html: true,
            container: 'body',
            title: dStart,
            trigger: 'click',
            content: function() {
                setTimeout(function () {
                    element.popover('hide');
                }, 2000);
                return $('#popover-content').html();
            }
        });
    },

在您的 HTML 中;

<ul id="popover-content" class="list-group" style="display: none">
  <a href="#" id="Eventaaa" class="list-group-item" onclick="aaa();">aaa</a>
  <a href="#" id="Eventbbb" class="list-group-item" onclick="bbb();">bbb</a>
  <a href="#" id="Eventccc" class="list-group-item" onclick="ccc();">ccc</a>
</ul>

<ul id="popover-day" class="list-group" style="display: none">
  <a href="#" id="Dayaaa" class="list-group-item" onclick="fDayaaa();">aaa</a>
  <a href="#" id="Dayyyy" class="list-group-item" onclick="fDayyyy();">yyy</a>
  <a href="#" id="Dayxxx" class="list-group-item" onclick="fDayxxx();">xxx</a>
</ul>

【讨论】:

    【解决方案2】:

    将弹出框附加到日历容器以滚动带有日历的弹出框。

                $(jsEvent.target).popover({
                    html: true,
                    container:'#calendar',
                    placement: 'right'
                });
    

    【讨论】:

      【解决方案3】:

      这段代码帮助了我

      $('#calendar').fullCalendar({
          eventRender: function (event, element) {
              element.popover({
                  title: event.name,
                  placement: 'right',
                  content: + '<br />Start: ' + event.starts_at + '<br />End: ' + event.ends_at + '<br />Description: ' + event.description,
              });
          }
      });
      

      引导版本 - 2.3.2,完整日历 - 1.6.4

      取自https://groups.google.com/forum/#!topic/twitter-bootstrap-stackoverflow/9pkC3_lodmY

      【讨论】:

      • 为了呈现 HTML,我还必须将 'html:true' 属性添加到弹出框。
      【解决方案4】:

      从 2.3 版开始,bootstrap 现在有一个用于弹出框的“容器”选项,它将弹出框附加到特定元素。

      只需添加 {container:'body'} 即可将其附加到正文

      $this.popover({html:true,title:event.title,placement:'top',container:'body'}).popover('show');
      

      【讨论】:

      • 这很好用,除非你滚动日历,现在弹出框相对于正文保持在相同的位置,但现在它与日历事件分离。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-06
      • 1970-01-01
      • 2013-01-22
      相关资源
      最近更新 更多