How to include additional dojo modules in a custom widget?

7
http://dojotoolkit.org/reference-guide/1.10/dojox/gesture.html I am trying to include this dojox module into a custom widget. But I cannot seem to get it nicely done. I don't want to add the javascript files to the Mendix runtime directory. They should be embedded within the custom widget. How can I do this? Kind regards, Marcus
asked
5 answers
5

Use the boilerplate code and change the header to

require({}, [
    'dojo/_base/declare', 'mxui/widget/_WidgetBase', 'dijit/_TemplatedMixin',
    'mxui/dom', 'dojo/dom', 'dojo/query', 'dojo/dom-prop', 'dojo/dom-geometry', 'dojo/dom-class', 'dojo/dom-style', 'dojo/dom-construct', 'dojo/_base/array', 'dojo/_base/lang', 'dojo/text',
    'dojo/text!BooleanSlider/widget/templates/BooleanSlider.html', 'dojox/gesture'
], function (declare, _WidgetBase, _TemplatedMixin, dom, dojoDom, domQuery, domProp, domGeom, domClass, domStyle, domConstruct, dojoArray, lang, text, widgetTemplate, gesture) {
    'use strict';

so add the the library to both the library list and to aliases. Use gesture in the widget to invoke.

answered
5

Does someone have any idea?

answered
2

Including a dojo module is not different from including any other library. You can just create a folder for the library and in the "define" of widget, include the path to the library correctly. You could take a look at some widget in github as example, many of them use 3rd party lib

answered
2

I want to comment that dojox/gesture/tap is not included in the mxclientsystem client runtime. You can however include the dojox/gesture/tap to your widget and then include it as such:

 require({}, [
'dojo/_base/declare', 'mxui/widget/_WidgetBase', 'dijit/_TemplatedMixin',
'mxui/dom', 'dojo/dom', 'dojo/query', 'dojo/dom-prop', 'dojo/dom-geometry', 'dojo/dom-class', 'dojo/dom-style', 'dojo/dom-construct', 'dojo/_base/array', 'dojo/_base/lang', 'dojo/text',
'dojo/text!BooleanSlider/widget/templates/BooleanSlider.html', 'BooleanSlider/widget/lib/dojox/gesture/tap'

In your AppStoreWidgetBoilerplate you will find a lib folder, place the folder dojox/gesture there and include it with "BooleanSlider/widget/lib/dojox/gesture/tap". Any dependencies to dojox/gesture/tap should also be included that way.

It might be possible that a certain "name" should be available in RequireJS... for instance 'jquery' and the path to where you might find it.

In that case you need to set a package for it.. You configure that like this (jquery as an example):

{
packages: [{ name: 'jquery', location: '../../widgets/WidgetName/lib', main: 'jquery-1.11.2.min' }]

},

answered
0

If you modify your customwidget.js to require the proper functions you need from that library like:

require(["dojox/gesture/tap"], function(tap){

var widget = {

// your custom widget code

};

mendix.widget.declare('customwidget.widget.customwidget', widget); })

Doesn't this work?

answered