Reusable Controls Issue

Is there a workaround for the errors when editing inside a reusable component for missing unknown components that belonged to the owning webpage?

This is very annoying, since the errors prevent you from editing and saving existing logic if you try to edit the reusable component.

These code events are actually working correctly, because the reusable component is referring to the legitimate Snackbar ID that exists on the containing webpage.

…But these can’t be removed, because it would be impossible to add it back again, since the Snackbar doesn’t exist inside the reusable component. Which means that you can’t actually change the block and have it saved.

It would be nice if when you try to edit a reusable component, you could edit the containing code from inside of the containing page, which would fix all of these errors. Or there needs to be a way to bypass the error checking so the reusable component code blocks can be saved anyway – this would be GREAT! :slight_smile:

In the meantime, does anyone have any JS examples for calling the Snackbar from a custom code block using the ID of the control?

Hello @Michael_Kadron

You could create Snackbar Action block with needed arguments in any page handler where it possible.

After that go to generated code section and copy content(it would be easier if at this handler snackbar action is only one codeless block, in that case, you could copy everything).

Go to the handler where you want to use this in Reusable Component and create Custom Code block.

Paste the content that was copied before.

I must mention - it is only a workaround, and there could be some unpredictable issues. But your need is valid, and we will discuss how we could implement that functionality.

Regards, Dima.

Thanks for waiting @Michael_Kadron

We discussed it with our development team and there are a few points of our discussion.

  • Everything that you experienced is expected behavior. After you made the component Reusable he lost the “context” of the owner page and become an independent entity that must no longer rely on the page where it was created. The reason of it - you could create one more instance of that component somewhere - and the action block that you already have could break the new page because it doesn’t contain some component that you trying to interact with (in our case - Snackbar).

  • Workaround that I offer you earlier is the corner case, you could use it, but it will be broken if you recreate your Snackbar, or if you try to reproduce the same logic on another page by creating a new Snackbar.

  • We have in our roadmap mechanism with events between Reusable Components and their owner’s pages that will satisfy your need.

Regards, Dima.

Hello Dima,

I have implemented the custom code workaround that you provided (Thank you! :slight_smile: and I have tested it using two different pages that have identical Snackbars (using the same Snackbar IDs on each page), and it works correctly.

Please elaborate on the possible issues recreating the logic block in a custom script on multiple pages.

Mike

From “Dima Vak via Backendless Support” <support-forum@backendlessmail.com>
To “Michael Kadron” <mike@hyperpixels.net>
Date 3/29/2023 9:53:27 AM
Subject [Backendless Support] [UI Builder] Reusable Controls Issue