Hotwire Discussion

TargetConnected won't be called

Hello,
i defined several targets, e.g.:
static targets = ['constraint'];
Now I want to execute some code, every time a target is added to the DOM (Ajax based content changes).
So I created a method called:

constraintTargetConnected(target)
{
    alert('hello');
}

The code is never executed… - Based on the docs this should work, or did I misunderstood anything here?

For values, which change their value :smiley:, it works like a charm by naming it like xxxValueChanged - So stimulus itself works, I really have only the problem with xxxTargetConnected naming/stuff.

Edit: Sorry I used stimulus 2 and TargetConnected is only available in stimulus 3 - I upgraded and now all works like a charm! (Default values are now also usable)