glide
glide copied to clipboard
Undefined method slice when clicking on a specific slider bullet.
I'm seeing the following error when clicking on individual slider bullet:
glide.esm.js:2046 Uncaught TypeError: Cannot read property 'slice' of null
This is because the event bubbles up to the slider parent during the following event handler (glide.esm.js:3242
):
click: function click(event) {
event.preventDefault();
Components.Run.make(Components.Direction.resolve(event.currentTarget.getAttribute('data-glide-dir')));
}
event.currentTarget.getAttribute('data-glide-dir')
returns nothing, since event.currentTarget
doesn't have that attribute, and then the resolve method at glide.esm.js:2045
immediately attempts to call slice(0, 1)
on the null object it was passed, and therefore breaks.
While the overarching click event DOES WORK, having this JS error happen is rather silly. Could we have the resolve function verify that it does indeed have something before trying to call slice, the initial offending click event not call resolve if it would pass it nothing, or have the click event not bubble?
Thanks!
(P.S. - I'm more than happy to open a PR for this, I just am not super familiar with the codebase and don't want to make any assumptions about your best practices!)
Getting this error too, when trying to call disabled()
.
Getting this error too, when trying to call
disabled()
.
Nevermind, it was because I was clicking a button I have included inside the .glide__arrows
container, so it was trying to find the same data-glide-dir
on my custom button (which didn't have that attribute).
Maybe it can give you any tips, @tylercrocker
@tylercrocker I am facing the same issue. Can you please share your solution?
I'm getting this error too :/
I figured out the reason for my case:
it was because I inserted bullets data-glide-el="controls[nav]"
into data-glide-el="controls"