For a custom widget I'm trying to subscribe to two attributes from the context object, one wich only triggers the updateRendering and one which instructs the widget to reload the data. Ive tried several options but none work.
Option 1: two subscribes
Update: I have no clue why, but this one does work now. Probably some hidden typo in it the first time, no idea why it didn't generate and error though.
var attrHandle = this.subscribe({
guid: this._contextObj.getGuid(),
attr: this._association,
callback: dojoLang.hitch(this, function(guid, attr, attrValue) {
this._updateRendering();
})
});
var reloadDataHandle = this.subscribe({
guid: this._contextObj.getGuid(),
attr: this.reloadDataAttribute,
callback: dojolang.hitch(this, function(guid, attr, attrValue) {
this._reloadData();
})
});
var validationHandle = this.subscribe({
guid: this._contextObj.getGuid(),
val: true,
callback: dojoLang.hitch(this, this._handleValidation)
});
this._handles = [attrHandle, reloadDataHandle, validationHandle];
No errors, but the script simply runs forever as soon as the second attribute subscription is reached. So the page is never loaded.
Option 2: see if the attribute subscription accepts an array
var attrHandle = this.subscribe({
guid: this._contextObj.getGuid(),
attr: [this._association, this.reloadDataAttribute],
callback: dojoLang.hitch(this, function(guid, attr, attrValue) {
this._updateRendering();
})
});
var validationHandle = this.subscribe({
guid: this._contextObj.getGuid(),
val: true,
callback: dojoLang.hitch(this, this._handleValidation)
});
this._handles = [attrHandle, validationHandle];
This seems to work fine, the page loads, again no errors. However the attrHandle is never trigerred when any of the attributes change.
Option 3: add an object handle, figure out later how to check what attributes where changed
var objHandle = this.subscribe({
guid: this._contextObj.getGuid(),
callback: dojoLang.hitch(this, function(guid) {
this._updateRendering();
})
});
var validationHandle = this.subscribe({
guid: this._contextObj.getGuid(),
val: true,
callback: dojoLang.hitch(this, this._handleValidation)
});
this._handles = [attrHandle, validationHandle];
However this comes with the problem that the object handle isn't called when any attribute changes (even though the console shows "mendix.sys.Data.update"), it's only called when I add an OnChange to the other input and refresh the entire object in the OnChange.
This is all in Mendix 6.10.2, does anyone have a solution for this?