Hi, I am converting a Mendix 6 widget to a Mendix 7 widget. Below is the relevant javascript code: define([ "dojo/_base/declare", "mxui/widget/_WidgetBase", "IFrameResizer/lib/jquery-1.11.2.min" // "dojo/text!IFrame/widget/templates/IFrameResizer.html" ], function (declare, _WidgetBase, _jQuery) { "use strict"; console.log("widget being initialized"); var $ = _jQuery.noConflict(true); In debugger mode, I see my console message, but on JQuery line I am getting a factory Threw error. This is due to the fact that the JQuery library is not an AMD JS library. See Console message: So my question is how do I use non-AMD libraries in a Mendix 7 widget ?
asked
Friso Nijboer
3 answers
2
If it is only jQuery then I would say take a look at the AppStoreBoilerPlate widget from Mendix on GitHub. It is built with an AMD version of jQuery loaded into the Main JS file.
answered
Ivo Sturm
0
Hello,
It's straightforward to convert your existing js library to an AMD-friendly format. I have followed and recommended this article to people before, and I think it lays out the steps well.
Once your module is AMD-friendly, you can load it just like any other module
answered
Conner Charlebois
-2
One option could be to modify the non-amd library to attach the widget to the window. eg:
var myNiceModule = someReferenceToYourLibrary
//This is inside that library
window.myNiceModule = myNiceModule
But if its just the jQuery library you are struggling with, get the version from the app store boilerplate.