I am currently detecting a button click, and then creating a room based on the button that is clicked, and the width and height of a certain div element. After the room forms, there is an option to return to the previous selection via another button. While the room forms, and the back button works as well, if I once more try creating the room after going back, the room doesn’t form, despite it still existing in the hierarchy. I am checking for button clicks using jquery in initialize. I tried shifting the jquery code to update, but that understandably returns undefined for the width and height as the HTML was defined only in initialize. Is there any reason why the room doesn’t form for a second time?
PROJECT - https://playcanvas.com/editor/scene/943414 (to debug, click let’s go, then any height, and then BTDV. Repeat. If any height is clicked for the second time, it won’t work.)
VIDEO -
EDIT - The entire ui.js file seems to be disabled. Why could this be?
So your issue is that when switching between a room and your main screen, you remove/append the HTML in the container div. But you apply the events only once, in your initialize method (ui.js).
To fix this you will have to apply your click handlers each time you append the HTML back in place.
Using the browser debug tools you can check how your code steps / how many times it executes.