2

There is an example widget using JQuery in {WAB root}/client/stemapp/widgets/samplewidgets/UseJQuery and the code can be easily adapted for other versions of JQuery. However, I want to use JQueryUI as well. I tried to duplicate jimu/loaderplugins/jquery-loader within the require array in the define statement:

'jimu/loaderplugins/jquery-loader!http://code.jquery.com/jquery-1.9.1.min.js',
'jimu/loaderplugins/jquery-loader!http://code.jquery.com/ui/1.10.3/jquery-ui.min.js'

But since doing this, the widget doesn't open in webappviewer and its code is no longer visible to FireBug, so this clearly is not the way. Seems I need some jqueryUI-loader, not existing in the standard jimu/loaderplugins directory. Is there any way to enable JQueryUI on the widget level, or do I need to configure init.js, hack the WAB code or even write my own jqueryUI-loader?

EDIT: I found an example of including the library in the head of Widget.html file. AFAIK widget templates should be short snippets not containing the head section so this seems too hacky and I would expect some trouble after doing this. Is this the only way to do it on the widget level?

I plan to publish the widgets to more apps, including those owned by those outside our organization, so tweaking the widget is preferred to doing it anywhere else. Changing WAB is not completely out of question though, if it's cleaner than this one.

1

I think the jQuery loader accepts a second argument of an array of pulgins to load along with jQuery. So doing your require like this should allow you to load the plugin

"jimu/loaderplugins/jquery-loader!./libs/jquery.min.js, ./libs/jquery-ui.js"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.