XPages fullCalendar不是一个函数

时间:2016-01-27 09:10:52

标签: jquery dojo fullcalendar xpages

你好我需要使用这个FullCalendar Scheduler Example Scheduler Code(如果你打开示例页面的源代码非常简单到不正确)

所以在我的XPages中,我创建了一个包含代码的XPages:

   <?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">



    <xp:div styleClass="calendarcss " id="calendar">

    </xp:div>


    <xp:scriptBlock id="scriptBlock1">
        <xp:this.value><![CDATA[$(function() { // document ready
        var x=x$("#{id:calendar}");
        x.fullCalendar({
            defaultView: 'agendaDay',
            defaultDate: '2016-01-07',
            editable: true,
            selectable: true,
            eventLimit: true, // allow "more" link when too many events
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'agendaDay,agendaTwoDay,agendaWeek,month'
            },
            views: {
                agendaTwoDay: {
                    type: 'agenda',
                    duration: { days: 2 },
                    // views that are more than a day will NOT do this behavior by default
                    // so, we need to explicitly enable it
                    groupByResource: true
                    //// uncomment this line to group by day FIRST with resources underneath
                    //groupByDateAndResource: true
                }
            },
            //// uncomment this line to hide the all-day slot
            //allDaySlot: false,
            resources: [
                { id: 'a', title: 'Room A' },
                { id: 'b', title: 'Room B', eventColor: 'green' },
                { id: 'c', title: 'Room C', eventColor: 'orange' },
                { id: 'd', title: 'Room D', eventColor: 'red' }
            ],
            events: [
                { id: '1', resourceId: 'a', start: '2016-01-06', end: '2016-01-08', title: 'event 1' },
                { id: '2', resourceId: 'a', start: '2016-01-07T09:00:00', end: '2016-01-07T14:00:00', title: 'event 2' },
                { id: '3', resourceId: 'b', start: '2016-01-07T12:00:00', end: '2016-01-08T06:00:00', title: 'event 3' },
                { id: '4', resourceId: 'c', start: '2016-01-07T07:30:00', end: '2016-01-07T09:30:00', title: 'event 4' },
                { id: '5', resourceId: 'd', start: '2016-01-07T10:00:00', end: '2016-01-07T15:00:00', title: 'event 5' }
            ],
            select: function(start, end, jsEvent, view, resource) {
                console.log(
                    'select',
                    start.format(),
                    end.format(),
                    resource ? resource.id : '(no resource)'
                );
            },
            dayClick: function(date, jsEvent, view, resource) {
                console.log(
                    'dayClick',
                    date.format(),
                    resource ? resource.id : '(no resource)'
                );
            }
        });

    });]]></xp:this.value>
    </xp:scriptBlock>
</xp:view>

只有在我使用 xsp.client.script.libraries = none

禁用Dojo时才能正常工作

如果删除上面的行,则firebug控制台会在 scriptBlock 的3行中显示此错误:

  

fullCalendar不是函数

有什么想法修复并启用相应的dojo库?

2 个答案:

答案 0 :(得分:2)

好的问题是AMD Loader ...... 解决方案是在DOJO之前插入代码......使用此声明

<xp:this.properties>
        <xp:parameter name="xsp.resources.aggregate" value="true" />
    </xp:this.properties>    
<xp:this.resources>
        <xp:headTag tagName="script">
             <xp:this.attributes>
                 <xp:parameter name="type" value="text/javascript" />
                 <xp:parameter name="src" value="jquery-2.1.4.min.js" />
             </xp:this.attributes>
         </xp:headTag>
         <xp:headTag tagName="script">
             <xp:this.attributes>
                 <xp:parameter name="type" value="text/javascript" />
                 <xp:parameter name="src" value="moment.min.js" />
             </xp:this.attributes>
         </xp:headTag>
        <xp:headTag tagName="script">
             <xp:this.attributes>
                 <xp:parameter name="type" value="text/javascript" />
                 <xp:parameter name="src" value="fullcalendar.min.js" />
             </xp:this.attributes>
         </xp:headTag>
          <xp:headTag tagName="script">
             <xp:this.attributes>
                 <xp:parameter name="type" value="text/javascript" />
                 <xp:parameter name="src" value="scheduler.min.js" />
             </xp:this.attributes>
         </xp:headTag>
    </xp:this.resources> 

答案 1 :(得分:0)