New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tab events #42
Comments
You can activate a tab via JavaScript using `mui.tabs.activate(paneId)`.
Would that work or do you need an event to attach to?
|
The activation of the tab must still be the old, manual way where a user clicks on the tab. I need an event for after the new tab is shown. Similar to Bootstrap shown.bs.tab |
Ok, let me think about it and I'll get back to you tonight. |
If you're going that route, a full event system for all kinds of events
|
Adding events won't add much overhead. Here's an example of how the <select> component dispatches a "change" event: For starters, how about something similar to Bootstrap (all events fire on tab element):
tabEl.addEventListener('mui.tabs.showstart', function(ev) {
// user has activated the tab
}); Another option is to trigger a more general event (e.g. on the window): window.addEventListener('mui.tabs.event', function(ev, type, paneId) {
// type is one of showstart|showend|hidestart|hideend
}); Let me know your thoughts! |
Also, if you have a few minutes, I'd love to get your opinion on the data-attributes proposal: #41 |
I prefer this approach:
But the old tab and new tab should be passed as parameters. Users will sometimes want to know which tab they're exiting. |
In terms of passing the old/new tabs how about using Bootstrap's method? tabEl.addEventListener('mui.tabs.showstart', function(ev) {
ev.target // newly activated tab
ev.relatedTarget // previous active tab
}); |
@igitur I implemented the spec defined above in the One subtlety is that events are dispatched on the "tab" elements ( |
@igitur Any thoughts on the tab events implementation? I'm wondering if it makes more sense to dispatch the event on the toggle element and to communicate the pane ID's instead: toggleEl.addEventListener('mui.tabs.showstart', function(ev) {
ev.paneId // pane ID of newly activated tab
ev.relatedPaneId // pane ID of previously active tab
}); |
@amorey I promise I'll look at this soon. Just give me a few days. |
Any updates on this? |
@simonkastenhuber The code is ready to go! Any thoughts on dispatching the event on the toggle element and passing the pane IDs like this: toggleEl.addEventListener('mui.tabs.showstart', function(ev) {
ev.paneId // pane ID of newly activated tab
ev.relatedPaneId // pane ID of previously active tab
}); |
Awesome! Sounds good to me |
@simonkastenhuber - Tab events are live in v0.1.22. Let me know if you run into any problems: https://www.muicss.com |
I added tab events documentation to the site: https://www.muicss.com/docs/v1/css-js/tabs |
hey @amorey! i've updated to the new version and it works like a charm. Thanks a lot. Keep up the great work! |
Nice! I'm glad to hear it's working well! |
I'm a bit late here, but just want to add that tab events are working well for me now. |
Great! Thanks for the update! |
Hi,
I'd like to attach a handler for when a tab is activated (because I have some flot charts that need to be redrawn).
Is there an existing event that I can attach to?
thanks
The text was updated successfully, but these errors were encountered: