FormWidget JS no longer working in OC3

Hi there.

One of our legacy FormWidgets that we use all of the time in our October 1.1 websites loads a series of Javascript in the loadAssets function using multiple calls to addJs() - a mixture of jQuery plugins, 3rd party libraries and then finally, the FormWidget specific JS itself.

This FormWidget is defined in the same way as the standard OC1 FormWidgets are.

We’re still in the testing phase of October 3.x but one of the test sites, on a Plugin that is using this FormWidget, is consistently showing multiple console errors “Uncaught Error: Can only have one anonymous define call per script file
at r.enqueueDefineAnonymousModule”

This in turn is causing our FormWidget to fail as it can’t find the JS classes it needs.

I’m guessing there have been internal changes between OC 1 and 3 that may be affecting things but I’m not sure how to fix it. I’ve tried switching to a single addJs call and passing an array but this seems to only reduce the number of “Can only have one anonymous define call” errors

Any help would be greatly appreciated! Thanks

Hi @WeSayHowHigh

This can happen when scripts are combined. One such solution is to wrap the problematic scripts with the following.

var globalDefine = typeof define == "function" ? define : null;
if (globalDefine) {
    delete define;
    define = null;

// ...Script goes here...

if (globalDefine) {
    define = globalDefine;

Amazing - that worked - thanks so much @daftspunky !

1 Like