Bricks Version: 1.5 beta Browser: Chrome 90 OS: macOS / Windows / Linux / etc. URL: localhost
Hey guys,
Today I experienced several times the same issue with the code element. When I made modifications to a JavaScript code, and saved it, it didn’t update on frontend. When I refresh the builder page, the old code is showing up without modifications. I had to copy/paste the code in a new code element in order to apply the modifications. The other fields get correctly updated.
Yes, have been experiencing this too. First save worked as expected. Second save after changing code did not save correctly… always defaulted back to initial code!
You have to click the “Run code” icon or use the “CMD/CTRL + R” keyboard shortcut to execute your code changes as mentioned in the Academy: Custom Code – Bricks Academy
This has always been the case since we introduced code execution.
Automatically executing your code after every keystroke or even with a slight debounce/timeout could put a lot of strain on your server. Especially if it’s resource-intensive PHP code.
But we’ll improve the logic to auto-execute the code for you on save and when clicking outside the code editor (blur) in the next release. The click has to happen on the control panel, though. Because if you click on the canvas the element is no longer being edited and won’t re-render in-time.
As a general rule of thumb & best-practice: Press “CMD/CTRL + R” after you’ve finished editing your code
Hey Thomas, the problem is not just that the code is not automatically running. If you make changes to the code, save it and click on another element, and re-enter in the code element, the changes disappeared and the changes aren’t saved.
When the code runs, it is persisted in the builder as well. Which is why the “CMD/CTRL + R” works.
But ya, I’ll throw in a code re-run whenever the mouse is moved and there are code changes that did not “run”. That should cover everything. You’ll see
Marking this one solved as non-PHP code (HTML, CSS, JS) runs automatically in the 1.5 RC2, and PHP code is executed as soon as you move your mouse, save, or use the "Run code"keyboard shortcut “CMD / CTRL + R”. The reasons for why this is necessary I explain & showcase in the following video: