Action descriptor and Bootstrap events


First of all, great framework! It does wonders on an existing rails backend. :+1:

I have a small issue where I use Bootstrap nav tabs and its events(
I’m trying to call a function when the is triggered. I tried to bind my function with>foo#bar but it doesn’t get called.

I’m sure that the DOM element having the data-action which is a simple <a>, is the correct one: if I try to bind an event listener on using JQuery, it works as expected.

My guess is that the event name,, can be an issue when Stimulus parses it. Perhaps having dots in the name is the problem.

Anyone has dealt with this before?

I workaround the situation using click->foo#bar but my event listener would be greatly simplified if I was able to call it on the proper event.

1 Like

Is a native event or a jQuery event? I think Stimulus doesn’t not work with jQuery events.

Ah yes, you must be right. I’ll take time to check that.

Thanks for your input!

Would you be able to provide your end solution? Thanks.

As guessed by @jwald1, is not a native event and thus does not work with Stimulus.

I ended up using a click event on the tab and waiting some ms (with setTimeout) to give time to the tab to be display. I know it looks like a ugly workaround but that’s the best I ended up with.

Let me know if you find a better way, in particular avoiding using setTimeout.