I have a dynamic questionnaire that is displayed on a page via object-repeat. Some questions have the option to attach a photo, when the user answers Yes. Since there are many questions, and only a few requirs photo, I would not like to create dummy photo’s instance for each question every time (so, have a photo only when it needs).
The solution works, but when I want to go to the page, the following error is displayed:
main.js:1 TypeError: Cannot read property 'bind' of undefined at SmartDisplayPhotoComponent.componentDidMount (vendor-@journeyapps.js:1073) at Ji (vendor-react-dom.js:1) at Sj (vendor-react-dom.js:1) at exports.unstable_runWithPriority (vendor.js:1) at cg (vendor-react-dom.js:1) at Jj (vendor-react-dom.js:1) at yj (vendor-react-dom.js:1) at Ig (vendor-react-dom.js:1) at bk (vendor-react-dom.js:1) at vendor-react-dom.js:1
I have made conditions “show-if” for photo component, but it turns out that the polling of values is still going on.
Current solution (Sorry, but my code doesn’t show without those spaces in tag names):
< object-repeat query=“questions” as=“result” >
< single-choice-radio label=“Question” bind=“result.answer” required=“true” on-change=“$:changeValue(result)” />
< display-photo show-if=“$:showSavedPhoto(result)” label=“Photo” bind=“result.photo.photo” />
</ object-repeat>
(result.photo.photo - question has a field “Photo” with model “photo”. The model “photo” has a field with attachment photo)
Is there any optimal solution without creating redundant elements for this situation (dynamic list of question, pictures are not needed everywhere)?