Error while adding extenal JQuery when creating a widget

0
Hi,   I'm creating a custom widget. I'm trying to add an external JQuery file(jquery-ui.js) and its supported css file(jquery-ui.css). But i'm getting the following error when the main js file is been loaded(widgetname.js). Can I know how exactly these file should be defined in the widgetname.js file to use them.       mxui.js?636510557655283240:29 Uncaught Error: dojo.require and dojo.provide are not supported in Mendix 7. Please, use AMD style for custom widgets.     at Object.window.dojo.provide.window.dojo.require (mxui.js?636510557655283240:29)     at DataGridExtensionNoContext.js?636510557655283240:1 window.dojo.provide.window.dojo.require @ mxui.js?636510557655283240:29 (anonymous) @ DataGridExtensionNoContext.js?636510557655283240:1 mxui.js?636510557655283240:5 GET http://localhost:8080/mxclientsystem/jquery.js?636510557655283240 net::ERR_ABORTED undefined.f.injectUrl @ mxui.js?636510557655283240:5 te @ mxui.js?636510557655283240:5 c @ mxui.js?636510557655283240:5 (anonymous) @ mxui.js?636510557655283240:5 qt @ mxui.js?636510557655283240:5 ft @ mxui.js?636510557655283240:5 (anonymous) @ mxui.js?636510557655283240:5 c @ mxui.js?636510557655283240:5 ne @ mxui.js?636510557655283240:5 i @ mxui.js?636510557655283240:5 r @ mxui.js?636510557655283240:5 mxui.js?636510557655283240:5 Error: scriptError     at l (mxui.js?636510557655283240:5)     at HTMLScriptElement.<anonymous> (mxui.js?636510557655283240:5) (anonymous) @ mxui.js?636510557655283240:5 (anonymous) @ mxui.js?636510557655283240:5 c @ mxui.js?636510557655283240:5 undefined.f.signal @ mxui.js?636510557655283240:5 (anonymous) @ mxui.js?636510557655283240:5 mxui.js?636510557655283240:29 Loading module failed! Check console log for more detailed debug information
asked
3 answers
1

I think the error means that the way to load library in your code is not acceptable anymore in mx7. Dojo.provide and dojo.require is old way. You can check the boilerplate of widget as example to do those things.

answered
1

Hi,

A lot of app store widgets use jQuery so i would try to copy their approach.

If i look at the HTML snippet for example https://github.com/mendix/HTMLSnippet/blob/master/src/HTMLSnippet/widget/HTMLSnippet.js
 

var scriptNode = document.createElement("script"),
scriptNode.type = "text/javascript";
scriptNode.src = //jquery path
domConstruct.place(scriptNode, this.domNode, "only");

Hope this helps,

Andrej

answered
0

Check the DragAndDrop support widget in the AppStore. It has the jquery UI library implemented as well:

https://appstore.home.mendix.com/link/app/36773/

answered