Hi Matt,
The approach I found best is:
Add JS files to lib folder
Add both the jQuery and jQuery plugin JavaScript file into your <widgetname>/widget/lib folder.
Correctly setup require
In your main widget file, add the libraries like below:
require({
packages: [
{ name: 'jquery', location: '../../widgets/<widgetname>/widget/lib', main: 'jquery-1-10-2' },
{ name: 'jqueryplugin', location: '../../widgets/<widgetname>/widget/lib', main: 'jqueryplugin'}
]
},[
"dojo/_base/declare",
"dojo/NodeList-traverse",
"mxui/widget/_WidgetBase",
"dijit/_TemplatedMixin",
"mxui/dom",
"dojo/dom-style",
"dijit/registry",
"dojo/keys",
"dojo/on",
"dojo/domReady!",
"dojo/dom-construct",
"dojo/_base/lang",
"dojo/parser",
"dojo/_base/array",
"dojo/text!ColorPicker/widget/ui/ColorPicker.html",
"jquery",
"jqueryplugin"
], function(declare, NodeList, _WidgetBase,_TemplatedMixin, dom, domStyle, registry,keys, on,ready,domConstruct,dojoLang,parser,dojoArray,widgetTemplate,jquery){
"use strict";
Add noConflict
To make sure your project does not get conflicts with other externally loaded versions of jQuery (multiple widgets from the AppStore do this), you have to include, after the above code:
var $ = jquery.noConflict(true);
These three steps should do the trick as it did for multiple of my widgets. Good luck!
There is a specific change you need to make in you jquery.js file to be able to load it as is mentioned (var $ = jquery.noConflict(true);).
See the following line from the AppStoreWidgetBoilerplate where "jquery" was removed: https://github.com/mendix/AppStoreWidgetBoilerplate/blob/0553e57b920f8867403768bca61ab367caac4574/src/WidgetName/lib/jquery-1.11.2.js#L10307
Hi all, thanks for the responses. I was able to find a satisfying minimal fix.
Line 8 of the plugin reads:
"function" == typeof define && define.amd ? define([ "jquery" ], factory) : factory("object" == typeof exports ? require("jquery") : jQuery);
I concluded that the string "jquery" is a path to the base jquery library. Thus, the fix was to update this string to the appropriate path:
"function" == typeof define && define.amd ? define([ "InputBoxOctober/lib/jquery" ], factory) : factory("object" == typeof exports ? require("InputBoxOctober/lib/jquery") : jQuery);
(To be explicit: InputBoxOctober (also my widget name) is the folder at the same level as package.xml, and within InputBoxOctober are lib and widget folders, and InputBoxOctober.xml.)