Widget on home page prevents app from loading

0
On my home page, I have a data grid with a listening data view. On the data grid, I have new/edit buttons with default pop up page, and on the New/Edit popup page I have my widget. Here, the widget works as expected. On the other hand, when I put my widget in the listening data view on the home page, the app fails to load. My suspicion is that I have missed something in my lifecycle methods that causes the widget to fail to load in a scenario like this where there is no context data. Though the widget seems to work if not on a home page, I don't see why that scenario should be excluded. Can anyone provide suggestions on missing/incorrect Javascript that may be the culprit? Briefly, the widget is an input field with enhanced masking functionality, and it is hooked to a String attribute of its context entity. define( [ "dojo/_base/declare", "mxui/widget/_WidgetBase", "dijit/_TemplatedMixin", "mxui/dom", "dojo/dom", "dojo/dom-prop", "dojo/dom-geometry", "dojo/dom-class", "dojo/dom-style", "dojo/dom-construct", "dojo/_base/array", "dojo/_base/lang", "dojo/text", "dojo/html", "dojo/_base/event", "InputBoxOctober/lib/jquery", "InputBoxOctober/lib/jquery-maskedinput", "dojo/text!InputBoxOctober/widget/template/InputBoxOctober.html" ], function (declare, _WidgetBase, _TemplatedMixin, dom, dojoDom, dojoProp, dojoGeometry, dojoClass, dojoStyle, dojoConstruct, dojoArray, dojoLang, dojoText, dojoHtml, dojoEvent, _jQuery, _maskedInput, widgetTemplate ) { "use strict"; var $ = _jQuery.noConflict(true); // Declare widget's prototype. return declare("InputBoxOctober.widget.InputBoxOctober", [_WidgetBase, _TemplatedMixin], { templateString : widgetTemplate, //CACHES _hasStarted : false, subHandle : null, divNode : "", inputBox : "", handle : "", delay_timer : "", currValue : "", obj : null, maskString : "", postCreate : function(){ console.log("startup"); if (this._hasStarted) { return; } this._hasStarted = true; if (this.maskString && this.obj !== null) { console.log("setting placeholder string") dojoProp.set(this.inputBox, "placeholder", this.maskString); //dojoProp.set(this.inputBox, "mask", this.maskString); $(this.inputBox).mask(this.maskString); } }, // mxui.widget._WidgetBase.update is called when context is changed or initialized. Implement to re-render and / or fetch data. update : function(obj, callback){ console.log("change 1") console.log(obj) console.log(callback) if(obj !== null) { console.log("change 1b") this.connect(this.inputBox, "onblur", dojoLang.hitch(this, this.onLeave)); this.connect(this.inputBox, "onfocus", dojoLang.hitch(this, this.eventInputFocus)); this.obj = obj; if (callback) { console.log("change 3") callback(); } } else { console.log("update function else branch") console.log(this.domNode) dojoStyle.set(this.domNode, "display", "none"); console.log(this.domNode) } }, eventInputFocus : function () { dojoClass.add(this.inputBox, "MxClient_formFocus"); }, onLeave : function () { if (this.maskString) { $(this.inputBox).mask(this.maskString); } if (this.inputBox.value !== this.maskString) { //if (this.obj.get(this.name) !== this.inputBox.value) { this.obj.set(this.name, this.inputBox.value); mx.data.save({ mxobj : this.obj, callback : dojoLang.hitch(this, function () { }) }); } this.delay_timer = null; this.executeMicroflow(this.onleavemf); }, executeMicroflow : function (mf) { if (mf && this.obj) { mx.data.action({ store: { caller: this.mxform }, params: { actionname : mf, applyto : "selection", guids : [this.obj.getGuid()] }, callback: function () { // ok }, error: function () { logger.error("InputBoxOctober.widget.InputBoxOctober.triggerMicroFlow: XAS error executing microflow"); } }); } } }); }); require(["InputBoxOctober/widget/InputBoxOctober"]);  
asked
1 answers
1

Hi Matt,

In your update function you validate if there is no context object and otherwise you just hide the domNode for your widget, but in the else statement you don't trigger the callback. This will mean the widget processor (or what it is called) will not get notified that you finished the update. When there is no context this might stop the page from loading.

Hope that helps.

Kind regards,

Mitchel

answered