user1903750
user1903750

Reputation: 339

TypeError: $ is undefined & ReferenceError: Foundation is not defined

i am trying to add foundation.js and foundation-topbar.js version 4 to page.tpl.php via theme.info in drupal 7. i can see that jquery and foundation js files added correctly -jquery above foundation js files - but i get this errors:

TypeError: $ is undefined
(Foundation.zj, this, this.document)); // foundation-topbar.js line 206 

 ReferenceError: Foundation is not defined 
 (Foundation.zj, this, this.document)); // foundation-topbar.js line 206

there is foundation-topbar.js

Upvotes: 1

Views: 11919

Answers (2)

Jeff Boshers
Jeff Boshers

Reputation: 21

The 'Foundation' that it's looking for is the class object. you'll need to include foundation.js that's in the same directory as the js libs you're using.

Upvotes: 1

JAMESSTONEco
JAMESSTONEco

Reputation: 2051

You will need to add links to the script in this order:

  1. Zepto or jQuery (but not both, Zepto replaces jQuery in Foundation 4)
  2. foundation.js
  3. foundation-topbar.js

$ is a shorthand for jQuery calls and functions. So $('') is the same as jQuery('') Zepto uses $ and is jQuery compatible so it is possible that you have both loading with a conflict, but without seeing the source it is hard to tell.

Upvotes: 4

Related Questions