9
Views
2
Comments
Solved
Carousel update results in query selector null error after submitting second image

Hi does anyone know how to prevent this error? I am having this error after uploading a second image to be displayed in a carousel. The second image seems to take the place of the first image (hence you see 2 duplicated images) and the error message appears.

I'm not sure why do I have this error as I used the same code from the first carousel I made. (Refer to Business Image section in the oml under Business Screen).

I suspect it's because of the carousel id in the SubmitSubserviceImage. I think it should be c2.id but it cannot be chosen.


Would be much appreciated if the solution includes a working oml solution. Thank you!

CarouselSubserviceimageserror.oml

mvp_badge
MVP
Rank: #72
Solution

Hi,

The reason you were not able to reference the c2 carousel Id runtime property is because the respective carousel widget is defined inside the List Widget i.e. each dynamically rendered instance of carousel in each record/row of the List widget will have it's own unique runtime/dynamic Id value to reference.

Implemented Code Changes

  • As a solution, I have encapsulated the upload and carousel widget inside the block and the same is referenced in the screen
  • Defined OnRender event action for the screen is not required, instead incorporate the same logic in the image remove and add screen action flow
  • Did some code refactoring in order to resolve the warnings

Please refer the attached updated .oml file


Hope this helps you!


Kind regards,

Benjith Sam

CarouselSubserviceimageserror.oml

Rank: #5609

Hi Benjith, thank you for the detailed explanation. One thing to note is that the main If condition should be removed otherwise the "Images Upload image(s)" portion will not show and I cannot add images. Other than that, it works as intended. Thank you!