Hello everyone,
After three days, war coding, to make a js file run, i have only this great place to ask, hoping that i'll find someone with good experience in js into WP to tell me what's wrong and how should i proceed to make it work.
First things first, i'm trying to implement a menu in a personal parent theme (i've tried to implement it for testing in underscores and in Twenty Thirteen).
1- After seting up the markup of my menu in a separate php file in the root of the theme folder (e.g. nav-top.php)
<ul id="gn-menu" class="gn-menu-main">
<li class="gn-trigger">
<a class="gn-icon gn-icon-menu"><span>Menu</span></a>
<nav class="gn-menu-wrapper">
<div class="gn-scroller">
<ul class="gn-menu">
<li class="gn-search-item">
<input placeholder="Search" type="search" class="gn-search">
<a class="gn-icon gn-icon-search"><span><?php get_search_form(); ?></span></a>
</li>
<li>
<a class="gn-icon gn-icon-download">Downloads</a>
<ul class="gn-submenu">
<li><a class="gn-icon gn-icon-illustrator">Vector Illustrations</a></li>
<li><a class="gn-icon gn-icon-photoshop">Photoshop files</a></li>
</ul>
</li>
</ul>
</div><!-- /gn-scroller -->
</nav>
</li>
<li><a href="http://tympanus.net/codrops">Codrops</a></li>
<li><!-- ... --></li>
<!-- ... -->
</ul>
I left the markup like this for testing. Working fine under an html file !
2- I tried just to wp_enqueue_script the two necessary files for the menu and wp_enqueue_style in fuctions.php, without registering in a function !
Then i used <?php get_template_part('nav', 'top'); ?> at the top of the header.php before the title of the site.
The css worked just fine, i could see the menu bar, but the js files where not working since the sidebar panel of the menu was not opening.
3- I tried to register and enqueue the scripts and the style in a function in functions.php, but i had the same result as before, the css was here and the js files where not working.
4- I tried to integrate the navigation directly in header.php after
a- just enqueue the scripts and the style
b- register and enqueue the scripts and the style in a function
BUT, the result was always the same css working, js not working.
In the title i type "JavaScript loading..." i can tell because i saw the code source of my page and they where here like the style.
Oh, just for more info, when i enqueue or register/enqueue the js files, i've tried to put them in the footer than in the header (true, false), than i tried to call jquery in the array( array('jquery') ),
nothing seems to work !
Finally, why three days for an hour of testing ?
Hell, because i've tried a lot of menu and the result was the same for all of them : css working, js loading but not working !
And i made a lot lot lot of reading :)
So, the problem is in my experience with js in WP, it's my fault :)
I hope that someone will help me to finally pass this step and go further in js into WP.
Thanks a lot in advance for your help :)