New Discussion

Notifications

You’re not receiving notifications from this thread.

I want to click on dynamically created HTML elements in stimulus js.

1
Javascript

for example in jquery we do this =>

So instead of...
$(".myclass").click( function() {
// do something
});

We do this....
$('body').on('click', 'a.myclass', function() {
// do something
});


example for Javascript =>
document.body.addEventListener( 'click', function ( event ) {
if( event.target.id == 'btnSubmit' ) {
someFunc();
};

} );

my question is that how i achieve this is in stimulus js ?
because i'm working with ruby on rails when i render a form from back-end it's data-action and other things not working but out of the form everying is working fine.

i'm done

Join the discussion
Create an account Log in

Learning Ruby on Rails? Join our newsletter.

We won't send you spam. Unsubscribe at any time.