[Glide warn]: Root element must be a existing Html node TypeError: this.root is undefined [ SOLVED ]
See original GitHub issueI have one slider included in two page like : index.html
, about.html
Two pages have same slider
index.html
: init slider one time
but in about.html
init two time on two slider with same class
[Glide warn]: Root element must be a existing Html node
TypeError: this.root is undefined
import Glide from '@glidejs/glide'
window.addEventListener('load', () => {
const customers = new Glide(".view-customers", {
type: "carousel",
startAt: 0,
perView: 6,
direction: "rtl",
autoplay: "10000",
breakpoints: {
1024: {
perView: 4
},
760: {
perView: 3
},
480: {
perView: 2
}
}
});
customers.mount();
})
html:
<div class="view-customers">
<div data-glide-el="controls"></div>
<div class="glide__track" data-glide-el="track">
<ul class="glide__slides">
<li class="glide__slide">
<div class="customer-img text-center"><img src="images/ISO.png" alt="" /></div>
</li>
<li class="glide__slide">
<div class="customer-img text-center"><img src="images/ISO.png" alt="" /></div>
</li>
<li class="glide__slide">
<div class="customer-img text-center"><img src="images/ISO.png" alt="" /></div>
</li>
<li class="glide__slide">
<div class="customer-img text-center"><img src="images/ISO.png" alt="" /></div>
</li>
<li class="glide__slide">
<div class="customer-img text-center"><img src="images/food.png" alt="" /></div>
</li>
<li class="glide__slide">
<div class="customer-img text-center"><img src="images/partners.png" alt="" /></div>
</li>
</ul>
</div>
</div>
what’s my mistake ? 😢
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
[Glide warn]: Root element must be a existing Html node ...
It will see that this is a string and make a single querySelector call. To initialize multiple sliders with same selector you have...
Read more >Rails 6 GlideJS carousel issues (without jquery) - Reddit
... dev tools in firefox I am seeing [Glide warn]: Root element must be a existing Html node / Uncaught TypeError: this.root is...
Read more >typescript-cheatsheet - GitHub Pages
A set of TypeScript related notes used for quick reference. The cheatsheet contains references to types, classes, decorators, and many other TypeScript ...
Read more >jQuery API Documentation
jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax ......
Read more >SyntaxError: missing ; before statement - JavaScript | MDN
You need to provide a semicolon, so that JavaScript can parse the source code correctly. Message. SyntaxError: Expected ';' (Edge) SyntaxError: missing ;...
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 Free
Top 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
Glide will not initialize for you multiple instances when you passing a selector string as parameters. It will see that this is a string and make a single
querySelector
call.To initialize multiple sliders with same selector you have to query collection of HTMLElements by yourself and initialize glide on each one individually (in a simple loop).
Here is the same solution with forEach instead of the older for loop: