Search code examples
jquerywordpresszurb-foundation-5

using Zurb Foundation with wordpress no conflict


I am currently developing a custom theme using foundation and _s I had a few questions.I have followed this tutorial Here enqued all my script etc and now its working.

My only concern is the jquery, on some forums is says that i have to deregister the jquery and then register another one etc. On some forums its says that i have to use a non conflict mode while others tell me just to enque it and thats it. what is proper practice in this case? I am not looking for a temporary solution I would like this theme to update without issue or breaking in the future.

In the case of using the non conflict method. I have created a file named foundation.js and have enqued it in the functions.php file with this code:

jQuery.noConflict();
jQuery(document).ready(function($) {
    $(document).foundation();
});

Is this the right method?


Solution

  • The jQuery library included with WordPress is set to the noConflict() mode. In noConflict() mode, the global $ shortcut for jQuery is not available. So in foundation.js you can just use:

    jQuery(document).ready(function ($) {
        jQuery(document).foundation();
    });
    

    check this link from the Codex