MxBlog

Howto - Mendix widget using Dojo AMD

My previous post, Howto - A simple Mendix 5 widget used the lagacy loader API to implement a customer widget. Here is the same widget using the AMD format.

console.log("StaticHtmlFragment.js");
require(
    ["dojo/_base/declare",
        "mxui/widget/_WidgetBase"],
    function (declare, _WidgetBase) {
        console.log("StaticHtmlFragment.js - init");
        return declare("HtmlFragment.widget.StaticHtmlFragment",[_WidgetBase], {
            inputargs: {
                htmlContent: ""
            },
            postCreate: function () {
                console.log("StaticHtmlFragment.js - postCreate");
                this.domNode.innerHTML = this.htmlContent;
                this.actLoaded();
            },
        });
    }
);
console.log("StaticHtmlFragment.js - init done");

More info on AMD can be found here: Introduction to AMD Modules.