Issues with _main.js -- functions 'not defined'

I’m having a difficult time trying to figure out exactly what’s wrong with my code. I’ve installed enquire.js by putting the uncompressed enquire.js code into assets/plugins and also putting '!assets/js/plugins/enquire.js' into the Gruntfile.js to ignore the third party file for errors.

However, my problem lies within trying to call enquire (and other functions) within the _main.js file, even outside of the var ExampleSite = { wrapper.

I keep getting errors like the following:
[L12:C1] W117: 'enquire' is not defined. enquire.register("screen and (max-width:767px)", {
from the jshint:all task

Where am I supposed to be putting these function calls? I was able to add my function call to the enquire.js file itself, after the library code… but that’s sort of hackish to me and messy.

I’m just wondering what the best way to include code, ideally within that fancy body_class JavaScript wrapper.

Have you tried placing the following before trying to use the variable?

var enquire;

I am not sure it will work but I have a feeling I used something similar when using verge gave me the same error

Thanks for the reply! That handles shutting jshint up, but instead produces an error in browser…

Uncaught TypeError: Cannot call method 'register' of undefined

You should edit the .jshintrc file located in the theme root folder and add the function name to the "predef" setting.

1 Like

Just looked it up and I actually did what Weslly suggested. I really should have taken a look before posting a reply. Well, now I won’t forget what to do next time :slight_smile: