Skip to content
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

Binding from external file produces an error #16

Open
gudata opened this issue May 3, 2012 · 2 comments
Open

Binding from external file produces an error #16

gudata opened this issue May 3, 2012 · 2 comments

Comments

@gudata
Copy link

gudata commented May 3, 2012

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?

@hakimel
Copy link
Owner

hakimel commented May 4, 2012

Looks like the stroll.js script hasn't been loaded when you're calling it. Does your external JS get included before stroll.js?

@gudata
Copy link
Author

gudata commented May 4, 2012

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants