Planning on developing Bricks features that doesn´t make sense as Elements cause they won´t output an HTML structure.
Elements have a very powerful attribute that “rerenders” its JS on real time at the builder:
public $scripts = [‘myscript’];
When developing Bricks features using JS outside of an Element´s logic I have to enqueue scripts affecting the iframe and frontend. However, their JS doesn´t affect the iframe on users real time editing.
So I´m looking to use Element´s scripts attribute at the iframe without declaring an Element class.
Checking Bricks code, this attribute is declared at the asbtract class Element that the rest of the elements inherit.
$this->scripts = apply_filters( “bricks/elements/$this->name/scripts”, $this->scripts );
That is the line that handles Element´s script logic at the iframe.
There is a note at that line telling it is undocumented.
Before going deeper at Bricks code I wanted to ask Bricks devs about the possibility to use Elements native scripts feature out of the box. It would also be very grateful to document it at devs docs so everyone wanting to extend Bricks functionalities affecting the iframe apart from crafting Elements have accessible ways to do so.