Custom widget wait on load.

1
Hi there, i am trying to manipulate the layout of a page in a widget. However in order to do this i need to ensure that the page is loaded before my widget continues with changing the page, is there an event i can hook onto? I have to add that this is a non contextable widget.
asked
2 answers
7

When the startup method of your widget is called, the entire form is loaded in the DOMTree, and all widgets are instantiated. To get notified when a widget is completely loaded, you can add an onLoad handler:

  widget.addOnLoad(handler);

This will invoke the handler once the widget is loaded, or immediately if already loaded.

A widget declared with mendix.widget.declare has an isLoadedRecursive method, which also can be used to delay a handler until all widgets in a given DOMNode are loaded.

  this.isLoadedRecursive(handler, node);

If you have an array of widgets which should be loaded before invoking a handler, you can also use:

  mendix.widget.fireOnReady(widgets, handler);
answered
0

If you mean by page the HTML page itself (index.html), you can use mx.addOnLoad(function)

If you mean a form, no, but you can use mendix.lang.runOrDelay(actionfunction, conditionfunction) to postpone some code until a certain condition evaluates to true.

You can check if your widget is in the DOMTree and visible by using dojo.marginBox(this.domNode).h > 0

answered