6

When I am loading my page I include a javascript library that is used to create graphs with the Google api. I am handling this with CoffeeScript in the front end. According to the tutorial I am initiating the library like: data = new google.visualization.DataTable();.

When I am parsing my produced JS code from CoffeeScript with JSHint I am getting an error that google is not defined. How can I show to the parser that the library is actually loaded and the object exists?

data = new google.visualization.DataTable();

PROBLEM:
'google' is not defined.

1 Answer 1

2

I have tried to call it from the window object like

data = new window.google.visualization.DataTable();

and it stopped complaining.

Sign up to request clarification or add additional context in comments.

2 Comments

Why is it working with window? I cannot see any class named like this in the API? Did you encountered any other problem while doing charts with coffee?
window is the global function wrapper for the DOM object. So when you import google graphs library is getting attached to it, If I understood right, no I haven't had any other issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.