簡體   English   中英

在聚合物的核心動畫頁面部分中渲染fullcalendar.io

[英]Rendering fullcalendar.io in polymer a core-animated-pages section

我有一個使用核心動畫頁面在我的部分之間進行轉換的應用程序設置。 在一節中,我嘗試呈現fullcalendar插件( http://fullcalendar.io/ )。 使用sbg-fullcalendar元素執行此操作: https : //github.com/Smorgasbord-Development/sgb-fullcalendar

如果將元素放在應用程序的第一部分中,則效果很好。 該應用會加載日歷並在domReady事件上呈現。 但是,我想包括在任何部分中,並且在執行時不會呈現。

我已經對sbg-calendar元素進行了更新,以偵聽core-animated-pages-transition-end事件。 calendar元素確實捕獲了該事件並嘗試創建了一個日歷,但仍然無法渲染。

渲染問題可能是因為jQuery選擇器無法在影子dom中工作嗎? 我對聚合物很陌生,不確定它的許多內部工作原理。

這是我的索引頁面。

<core-animated-pages id="pages" selected="{{selected}}" transitions="cross-fade fade-slide-up fade-scale" fit>

        <section layout vertical>

            <categories-page class="page" id="categories" cross-fade?="{{largeScreen}}" fade-slide-up?="{{!largeScreen}}" heading="{{heading}}" flex></categories-page>
        </section>

        <section layout vertical>
            <calendar-page  class="page" cross-fade?="{{largeScreen}}" fade-slide-up?="{{!largeScreen}}" heading="{{heading}}" flex></calendar-page>
        </section>
    </core-animated-pages>

和日歷頁面:

<link rel="import" href="../base-page/base-page.html">

        <!-- Main -->
        <div main layout vertical>
            <core-header-panel id="headerPanel" mode="seamed" flex>
                <core-toolbar>
                    <paper-icon-button icon="menu" core-drawer-toggle>
                    </paper-icon-button>
                    <div id="title" flex>{{heading}}</div>

                    <paper-menu-button id="menuBtn" noink>
                        <paper-icon-button icon="more-vert" noink></paper-icon-button>
                        <paper-dropdown class="dropdown" halign="right">
                            <core-menu class="menu">
                                <paper-item>Settings</paper-item>
                                <paper-item>Help</paper-item>
                                <paper-item>Feedback</paper-item>
                            </core-menu>
                        </paper-dropdown>
                    </paper-menu-button>

                </core-toolbar>
                <div class="content" style="max-height:1000px;">

                        <sgb-fullcalendar id="calendar" defaultView="month"></sgb-fullcalendar>

                </div>
            </core-header-panel>
        </div>
</template>
<script>
    (function () {
        Polymer({
            willPrepare: function () {
                this.super();

            },
            getUrl: function (idx) {
                console.log(window.location.pathname + '/' + idx);
                return '/subjects/' + idx;
            }              
        });
    })();
</script>

我也一直在使用Rob Dodson的通訊錄應用程序作為我的應用程序的示例。

我已經通過使用domReady方法成功地在我的部分之一中渲染了fullCalendar(我也使用了核心動畫頁面)。 這是我將如何處理您的情況:

<polymer-element name="calendar-page" attributes="Your Attribute">
<template>
    <style>
        :host {
            display: block;
        }
    </style>
    <link rel='stylesheet' href='../fullcalendar/fullcalendar.css'>
    <div id='calendar'></div>
</template>
<script>
    Polymer("calendar-page",{
        domReady: function() {
          $(this.$.calendar).fullCalendar({
                weekends: false ,
                allDaySlot: false,
                minTime : "06:00:00",
                maxTime : "18:00:00",
                defaultView: 'agendaWeek',
                header: {left:'title', center: 'agendaDay,agendaWeek,month', right:  'today prev,next'},
                googleCalendarApiKey: 'YourApiKey',
                events: {
                    googleCalendarId: 'YourCalendarId',
                },
                eventClick: function(calEvent, jsEvent, view) {
                    //console.log(calEvent);
                    return false;
                },
            })
        },
    });
</script>

不要忘記從元素內部鏈接css文件。 希望有幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM