Been a WP dev for 8 years, this problem has never gone away and it's driving me insane. $ is not a function
always show up, or jQuery is not a function
, or foundation is not a function
... someone help me nip this in the bud once and for all?
My enqueue.php:
// initialize packages ...
function source_enqueue() {
// init $wp_styles variable
// adds conditional wrapper around ie stylesheet
global $wp_styles;
if (!is_admin()) {
// jquery, bower, foundation, app js, style, app css
// init jquery ...
wp_enqueue_script( 'jquery' );
// init foundation
wp_enqueue_script( 'foundation', 'https://cdn.jsdelivr.net/g/foundation@5.5.1(js/foundation.min.js+js/vendor/fastclick.js+js/vendor/jquery.cookie.js+js/vendor/jquery.js+js/vendor/modernizr.js+js/vendor/placeholder.js),camanjs@4.1.2', array(), '2.1.3', true );
// init normalize
wp_enqueue_style( 'foundation', 'https://cdn.jsdelivr.net/g/foundation@5.5.1(css/normalize.css),fontawesome@4.4.0,animatecss@3.4.0', array(), '', 'all' );
// init app.min.js
wp_enqueue_script( 'app', get_template_directory_uri() . '/assets/dist/app.min.js', array( 'jquery' ), '', true );
// init app.min.css
wp_enqueue_style( 'app', get_template_directory_uri() . '/assets/dist/app.min.css', array(), '', 'all' );
// init style.css
wp_enqueue_style( 'style', get_template_directory_uri() . '/style.css', array(), '', 'all' );
// init comment reply ...
if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) {
wp_enqueue_script( 'comment-reply' );
}
}
}
// init source_enqueue() ...
// - - - - - - - - - - - - - - - - -
add_action( 'init', 'source_enqueue' , 999 );
My app.js:
$.noConflict();
$(document).foundation();
I have tried wrapping it in different functions to no avail:
jQuery(document).ready(function(){
jQuery(document).foundation();
});
or:
$(document).ready(function(){
$(document).foundation();
});
Nothing works. The error still remains: $ is not a function
.
Someone help me solve this once and for all before I go mad and throw my nice desktop into a woodchipper?