Multiple instances of custom widget

1
0
-1

Hi All,

I'm writing a custom widget that will be instantiated multiple times in a form.

How can I reference this specific instance elements in the controller function?

I tried generating random id´s, but it seems the template is not ready when the controller function is executed, so $("#" + randomId) generates a JavaScript exception.

Thank you.

1 answer

1
0
-1
This one is the BEST answer!

Hi,

What are you trying to achieve? Normally the controller will have access only to the data manipulated by its template. So even though, we put multiple times the same widget on the a single page, the behavior of the widget should be affected.

By example, here you can find the source code of a fileUpload widget. You can did a test where you declare multiple times the fileUpload widget on a page, you will see that each widget manage its own file.

Cheers

Comments

Submitted by edo_2 on Thu, 07/20/2017 - 22:20

Lionel,

Thank you for your answer.

In fact, we were building the customAutoCompleteInput, which we found in the repository. Duh!

Best regards.

Notifications