Menu icon Foundation

Developer | Preston, Lancashire, UK

I'm an Android app developer and web designer based in Preston, Lancashire.

My Posts


My Comments

Stephen Mullen commented on Efren Perez's post over 4 years

Try changing the $ to jQuery and add jQuery.noConflict(); above the script
eg:
jQuery.noConflict();
jQuery(function() {

Stephen Mullen commented on Matt Shirey's post over 5 years

The jQuery that comes with WordPress uses noConflict. You need to change $(document).foundation(); to jQuery.noConflict();jQuery(document).foundation();
Also, you should enqueue your JavaScript so that it loads the jQuery that comes with WordPress. If you load it via an alternate in your theme folder then you may end up with 2 conflicting copies when a plugin loads the one from WordPress as well.

function load_my_scripts() {
  wp_enqueue_script(
    'foundation_js',
    get_template_directory_uri() . '/js/foundation.min.js',
    array('jquery'),
    '5.0.2',
    true
  );
  wp_enqueue_script(
    'foundation_init_js',
    get_template_directory_uri() . '/js/foundation_init.js',
    array('foundation_js'),
    '1.0',
    true
  );
}

add_action('wp_enqueue_scripts', 'load_my_scripts',0);

The foundation_init.js in this example contains the jQuery.noConflict();jQuery(document).foundation();

Posts Followed

No Content

Following

    No Content

Followers

My Posts

My Comments

You commented on Efren Perez's post over 4 years

Try changing the $ to jQuery and add jQuery.noConflict(); above the script
eg:
jQuery.noConflict();
jQuery(function() {

You commented on Matt Shirey's post over 5 years

The jQuery that comes with WordPress uses noConflict. You need to change $(document).foundation(); to jQuery.noConflict();jQuery(document).foundation();
Also, you should enqueue your JavaScript so that it loads the jQuery that comes with WordPress. If you load it via an alternate in your theme folder then you may end up with 2 conflicting copies when a plugin loads the one from WordPress as well.

function load_my_scripts() {
  wp_enqueue_script(
    'foundation_js',
    get_template_directory_uri() . '/js/foundation.min.js',
    array('jquery'),
    '5.0.2',
    true
  );
  wp_enqueue_script(
    'foundation_init_js',
    get_template_directory_uri() . '/js/foundation_init.js',
    array('foundation_js'),
    '1.0',
    true
  );
}

add_action('wp_enqueue_scripts', 'load_my_scripts',0);

The foundation_init.js in this example contains the jQuery.noConflict();jQuery(document).foundation();

Posts Followed

No Content

Following

  • No Content

Followers

  • No Content