Hello,
We are trying to create a dynamic form which when the user enters a value, a change handler is triggered to then save that value via some custom logic. The below code shows a basic example of what is trying to be done:
All the initialisation code, including the binding of the change handlers, should logically go into the initWidget method, but there is a slight complication in that some components such as TimeItem uses the FormItem.setValue() api to set the default value (or at least that seems to be the case from the browser tools call stack) on component creation, which then triggers the change handler incorrectly, causing the form to persist (via the handle method) with the default value.
In the above example, we would want the entirety of the CustomForm.create() call to execute without triggerring the changed method.
What would be the recommended way of hooking into the component creation lifecycle to accomplish this?
As a shortcut, we have currently split out a separate method to bind the change handlers but would ideally like to put that logic into the initWidget method body.
We are trying to create a dynamic form which when the user enters a value, a change handler is triggered to then save that value via some custom logic. The below code shows a basic example of what is trying to be done:
Code:
isc.ClassFactory.defineClass("CustomForm", "DynamicForm").addProperties({ initWidget: function(){this.Super('initWidget'); if(this.addChangeHandler) {this.getField('timeField').changed = alert('Saving form...');}} }); isc.CustomForm.create({ ID: "timeForm", numCols: 4, width: 650, addChangeHandler: true, fields: [ {name:"timeField", title:"Input time", type:"time", wrapTitle:false} ] });
In the above example, we would want the entirety of the CustomForm.create() call to execute without triggerring the changed method.
What would be the recommended way of hooking into the component creation lifecycle to accomplish this?
As a shortcut, we have currently split out a separate method to bind the change handlers but would ideally like to put that logic into the initWidget method body.
Comment