It is correct that update is triggered when the object changes. But, a widget usually subscribes to changes on the object as well. This means that if an attribute changes (which is used in conditional visibility?), an update or updateRendering (a common private method) is triggered as well.
Is it possible for you to share the widget code? (For example on Github or https://gist.github.com)
Hi,
I cannot share the code, but I run a test project.
Starting from the boilerplate I just modified the update function in the following way
update: function (obj, callback) {
logger.debug(this.id + ".update");
this.addText();
if(callback){
callback();
}
},
addText(){
let textDiv = dom.create("div", {});
textDiv.innerHTML = this.messageString;
this.domNode.appendChild(textDiv);
}
In my test project I have a very simple domain model; I have a popup with nested containers having conditional visibility based on three booleans, and as I open the popup the update function is called three times, and I see three times my message. I removed the updateRendering function, all other methods, and I am not subscribing to any object in the widget.
Hi Lucia,
This behavoir is probably fixed in Mendix 7.3 release
https://docs.mendix.com/releasenotes/desktop-modeler/7.3
Cheers
Andries
Update; the the name implies is update whenever the client assumes an update might be relevant to any of its children.
Though one, would be more efficient.
The update function should based on the received object, change the widget if needed. Though it is not good to "add"/"append" stuff in the update as you don't know how many times it will be called. So start from scratch every update or update you content
The constructor and postCreate function is called one.
And the update function often call an updateRendering function that will display based on the content of the context.
Please note the difference betwean update and subcribe.
update, when the context changes. Subscribe is in you own control
https://apidocs.mendix.com/7/client/mx.data.html#.subscribe
It not recomended to let your subscribute update to call you update function, most times its call the updateRendering