Reputation: 10111
I am converting some older JS into stimulus.
$(document).on('cocoon:after-insert', function(e, element) {
$some_inputs.change(updateMethodName)
})
The cocoon add partial looks like
= link_to_add_association 'Add Something', f, :method, partial: 'path/some_fields', class: 'btn btn-primary', 'data-action': 'click->stimulus-controller.someMethod'
This is te HTML outout
<a class="btn btn-primary add_fields" data-action="click->stimulus-controller.someMethod" data-association="..." data-associations="..." data-association-insertion-template="..." href="#">Add Something</a>
Now someMethod us working as I am calling it on connect but I am having problems calling it from the user interface.
Upvotes: 0
Views: 475
Reputation: 10111
The problem with this is
<a class="btn btn-primary add_fields" data-action="click->stimulus-controller.someMethod" data-association="..." data-associations="..." data-association-insertion-template="..." href="#">Add Something</a>
should change to
<a class="btn btn-primary add_fields" data-action="click->stimulus-controller#someMethod" data-association="..." data-associations="..." data-association-insertion-template="..." href="#">Add Something</a>
the .
needs to change to #
Upvotes: 1