XPages fullCalendar不是一个函数



你好,我需要使用这个 FullCalendar 调度程序示例调度器代码(如果你打开示例页面的源代码非常简单)

所以在我的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 不是一个函数

修复和启用相应道场库的一些想法?

好的,问题是AMD加载程序...解决方案是在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> 

另一种选择可能是来自Ferry的AMD黑客攻击:https://openntf.org/XSnippets.nsf/snippet.xsp?id=hack-to-use-jquery-amd-widgets-and-dojo-together

相关内容

  • 没有找到相关文章

最新更新