Instantiate multiple instances with the same selector
See original GitHub issueI’m trying to run multiple instances of Tabby on a page and can get this to work if I give each instance a unique selector and instantiate them independently:
<script>
var tabs = new Tabby('[data-tabs-1]');
var tabs = new Tabby('[data-tabs-2]');
</script>
Is there instead a way to instantiate all instances on the page which share a common selector?
Many thanks in advance.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Javascript prototyping reuse on multiple instances of the same ...
Finally, I want to invoke this prototypal 'plugin' each time per selector using the same selector, for example: var hello = new Hello('....
Read more >Matching Multiple Selectors On The Same ... - Ben Nadel
Multiple selector matches on a single element leads to only a single Directive instance. As you can see, even through we matched both...
Read more >Use multiple TinyMCE instances in a single page | Docs
Multiple editor instances sharing the same configuration. The following example breaks the page into two separate editable areas. Each area shares a single ......
Read more >Matching Multiple Selectors On The Same Element ... - Vimeo
Ben Nadel demonstrates that matching multiple attribute selectors on a single HTML element only produces one Directive instance for that ...
Read more >How to avoid Angular injectable instances duplication
Basically I want to use the same settings for a whole application: ... But sometimes Angular can create more than one instance of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This doesn’t seem to be possible at the moment, since Tabby runs
querySelector
on the selector, which by default only returns the first instance of the elements matching the selector.You could probably solve this by running your own
querySelectorAll
to find all instances of your tabs, then initiate all of them separately. Try something like this (untested):@arnojong I think this should work (untested):
Please note that all code needs to be within the
for..of
loop