Bug
question.value is undefined in afterRender if set to an empty array
That I can assign question.value in afterRender to be equal to an empty array
let getOpCodesWidget = () => {
var widget = {
name: "myWidget",
isFit: function (question) { return question["renderAs"] === 'myWidget'; },
htmlTemplate: myWidgetTemplate,
afterRender: function (question, el) {
question.value = [];
question.value.push('item'); // this fails because the value is undefined
}
}
return widget;
}
@faso Could you try:
let newValue = [];
newValue.push('item');
question.value = newValue;
Thank you,
Andrew
But if I do
let newValue = [];
question.value = newValue;
It's still undefined. Why so?
@faso Because the library change the empty array into undefined value, if the array is empty. Empty array should not be in the survey result and required value check should produce the error.
Thank you,
Andrew
Alright, thank you for quick answers. Always a joy to get help from you guys!