Improvements about creating elements

Reference: Create Your Own Elements – Bricks Academy

  1. There should be a method where we can do something on the controls’ setting such as saving it into database. Currently I’m doing this inside the render() method, but if rerender is set to false for the control, then we have NO WAY of updating the setting to the database since the render() method will not be triggered. Therefore, it’s necessary to have a method for us to do something with the controls’ setting on some conditions such as when we save the changes on the builder.

  2. The enqueue_scripts() method should be after the settings are being populated inside the init() method of the class \Bricks\Element. The reason is that sometimes we want to enqueue the styles and scripts dynamically based on the controls’ setting.

  3. The $scripts = []; will run the functions when updated in the builder, but it will still throws error in the console because I guess these functions are run before the elements are rendered at the first place, then it load again at some point after the elements is rendered in order for the functions mentioned in $scripts = []; to be working in the builder.

  4. The stylesheets being enqueue in the builder will not be updated with canvas reloading or saving the changes unless reload the builder/page. This is related to the second improvement above, for example: When we have a control with options for choosing elements’ layout, we want to enqueue stylesheet dynamically based on the layout, and the canvas should be reloaded with the updated stylesheets. Currently this is not possible.

  5. It would be great if we can use our own icons for the elements.

2 Likes