Question Editor API Events
input:added
Fires when the Widget (Question or Feature) view has an input field added.
You would want to be notified about this event firing because you might want to run some custom logic to the HTML when an input field is added.
This event is fired for each field when a new Widget is created or edited, and when an author adds a new field, for example, an multiple choice question option.
The on()
or once()
methods can be used to listen to this event.
Note This is fired for each attribute path added - so adding a single multiple choice option, for example, may result in this firing several times, once for each path.
Examples
// Run each time the event is fired
authorApp.on('widgetedit:input:added', function (event) {
console.log('This code executes when an input it added (for each attribute path). It contains the attribute path of the input element at event.attributePath and the HTML element at event.el');
});
Callback arguments
-
input_view object
Additional information about the added input field.
-
attribute_path string
See Internationalization which contains information about attribute paths.
-
el object
The HTMLDomElement.
-