search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Using Daypilot Calendar with RequireJS

Asked by Nick
4 years ago.

Hi,

We use RequireJS for bundling so we'd like to know how to go about doing this specifically for the calendar.

We're using the lite daypilot-calendar-src.js source file, which looks like it makes use of daypilot-common-src.js, so our current require.config.js file looks like this:

"paths": {
"daypilot-common": "Vendor/DayPilot/daypilot-common.src",
"calendar": "Vendor/DayPilot/daypilot-calendar.src"
},
"shim": {
"calendar": {
"deps": ["daypilot-common"]
}
}

...and each of the source files (calendar and common) have been updated to include the require define function, like this:

define(["Vendor/DayPilot/daypilot-common.src"], function () {
"use strict";

return function CalendarViewModel() {
[Original source here]
}
}

...and finally, in the page where we'd like to display the calendar, we have the following javascript:

<script>
require(["calendar"], function (daypilotCalendar) {
var dp = new daypilotCalendar();

.....[Other code to configure the calendar]
</script>

I can see in Chrome's network tab that both files are loaded correctly (common.src first), but as soon as the "var dp = new daypilotCalendar();" line is hit, I get the following error:

Uncaught TypeError: DayPilot.am is not a function
at registerAngularModule (daypilot-calendar.src.js:3411)

What am I missing?

Thanks,

Comment posted by Nick
4 years ago.

Any suggestions, guys...?

Comment posted by Nick
4 years ago.

I presume this isn't actually possible (potentially due to the misuse of the global namespace!)?

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.