We need to handle the onchange/onclick event of a CheckBoxItem. I don’t see how to do this in the documentation.
Scope issues
I’m having problems getting the changed handler to execute in the right context (or perhaps some other issue). A changed event has to call a function on the main Window object that contains the DynamicForm, like
isc.defineClass("CustomerWindow", "Window");
isc.CustomerWindow.addProperties({
initWidget : function () {
this.Super("initWidget", arguments);
this.customerCheckBoxButtons = isc.DynamicForm.create({
parentObj: this,
fields: [{editorType:"CheckboxItem",
changed:"billToClickHandler()"}
],
billToClickHandler: function() {
this.parentObj.showClickedMessage();
}
});
}
showClickedMessage: function() {
isc.say("clicked");
}
}
This is a pattern that I’ve used in the past and has worked. In this usage, showClickedMessage is erroring out as not defined when the checkbox is clicked. I’ve tried various permutations of setting onchanged to something like
changed: this.getID() + '.showClickedMessage'
with no success.
During the DynamicForm create(), it must call constructors for each FormItem (in this case a CheckboxItem). So when setting up the changed handler, how do I reference a method on the Window?
Hi Pallen,
changed() is passed the form as the first parameter, so one approach is simply:
changed:"form.billToClickHandler()"
Your approach of this.getID() + “.showClickedMessage” should also work but you omitted parens (it should be “.showClickedMessage()”).