The change function is called when there is a change in binding or configuration data.
| Property | Type | Description |
|---|---|---|
| type | String | Valid values are "binding" and "config". The default value is "binding". If the value is not "config", then it is "binding" by default. |
| property | String | The property that was changed |
| oldVal | For simple types, the previous value | |
| newVal | new value | |
| insertedInto | integer | For arrays, the index where the object was added to the list |
| removedFrom | integer | For arrays, the index where the object was removed from the list |
The following change event code is from the Output Text stock control. The code checks if a configuration property has changed, and updates the view with the new value. At the end, it calls the view() change event.
1 if (event.type == "config") { 2 if (event.property == "_metadata.label") { 3 var label = this.context.element.querySelector(".outputTextLabel > label"); 4 label.innerHTML = this.context.htmlEscape(event.newVal); 5 } else if (event.property == "_metadata.helpText") { var label = this.context.element.querySelector(".outputTextLabel > label"); label.title = event.newVal; } } else { var newData; if (event.newVal != undefined) { newData = event.newVal; } else { newData = ""; } 6 this.context.element.getElementsByTagName("span")[0].innerHTML = this.context.htmlEscape(newData); } 7 this.view();