Good afternoon,
I am using SurveyCreator from 'survey-creator-react'.
I am trying to add a custom css class to a question. I'm trying to use onUpdateQuestionCssClasses but it's not working.
I do get a response when using the onUpdatePageCssClasses method but not the question one.
The code I'm using:
Codeconst creator = useMemo(() => {
return new SurveyCreator({
haveCommercialLicense: true,
isAutoSave: true,
showTranslationTab: true,
showJSONEditorTab: user.role === 'ADMIN',
});
}, []);
useEffect(() => {
creator.JSON = currentQuestionnaire?.definition;
creator.survey.onUpdateQuestionCssClasses.add(function (survey, options) {
console.log('1/ onUpdateQuestionCssClasses');
});
creator.survey.onUpdatePanelCssClasses.add(() => {
console.log('2/ onUpdatePanelCssClasses');
});
creator.survey.onUpdatePageCssClasses.add((sender, options) => {
console.log('3/ onUpdatePageCssClasses');
console.log(options);
});
creator.saveSurveyFunc = async (saveNo: string, callback: (saveNo: string, isSaved: boolean) => void) => {
try {
await save();
callback(saveNo, true);
} catch (error) {
callback(saveNo, false);
}
};
}, [creator]);
return (
<SurveyCreatorComponent creator={creator} />
)
As you can see I only get the logs related to pages but not for questions:
When is that method triggering? I need to update the css when the survey creator is rendered.