Init ( bricVersion , framework )

The file “custom-brics.js” contains the following comment at the top:

///////////////////////////////////////////////////////////////////
// The Init function is called when bric is first selected //
// Use it to make changes to the initial state of the sidebar UI //
/////////////////////////////////////////////////////////////// ////

However, the function is called again and again when Bric is selected. If I click on another element and then back on ther Bric, the init routine is called.

This means that if I use this routine for initialization the first time, changes may be overwritten because it is initialized again.

Do I have to manage the one-time initialization myself, or am I completely on the wrong track?

The initialise function is triggered when a Bric is selected every time (that’s normal functionality)

You could set a html tag on first init on the item and sync it back, then check for the tags existence on future selections (init).

However, be careful using syncs in the init as it can cause an infinite loop if it’s not managed properly.

@Norm, thank you for your suggestions. I will solve it with an HTML tag, as you mentioned.

1 Like