JS in FormWidget inside a repeater field


I have my FormWidget placed inside a repeater and inside my FormWidget there’s some JS.

When I place the FormWidget outside the repeater, the JS is called properly.

How can I make it that my JS is called on press add repeater item?

I may could have a add repeater click listener in my global JS and then refresh partial like this:

$.request('onRefreshTime', {
    update: { mytime: '#myDiv' }

But I would like to have everything in a proper place…

I now placed my JS inside my plugin and addJs in plugin.php boot, so it’s almost in the right place.

I made a volatility error. I did this:


Instead of this:


:thinking: :man_facepalming:

I placed my assets now again into my FormWidget and it is working. I also implemented an element observer, to call my JS, when a new repeater item is added. Here you can see, how to setup such a observer: