stroll.js
stroll.js copied to clipboard
Binding from external file produces an error
If I load the following js from external file
(function() {
stroll.bind('#sidebar nav.categories div.scroll ul');
}).call(this);
I got an error
Uncaught TypeError: Cannot read property 'classList' of null
isCapablestroll.js:229
window.stroll.bindstroll.js:242
(anonymous function)store.js:3
(anonymous function)
If I do
stroll.bind('#sidebar nav.categories div.scroll ul');
from the console or
<script> stroll.bind('#sidebar nav.categories div.scroll ul');</script>
tags its working.
Any ideas what I am doing wrong?
Looks like the stroll.js script hasn't been loaded when you're calling it. Does your external JS get included before stroll.js?
I have posted the wrong error, now I have correct the question.
It seems that the .js file is loaded and I see it there. The problem is in the
function isCapable() {
return !!document.body.classList;
}
Where the document.body is null?! and thats why I get the "Cannot read property 'classList' of null".
What is the difference by invoking the stroll.bind from a js file and running it from the chrome js console? Maybe the dom isn't loaded? but I am in a function(){} so this code should be called when the dom is loaded. no idea :)