0

I use Bootstrap for a few things in my Plugin. Now i want to move the needed js to an externeal file. But if i do this it stops working. I already searched a while but i can´t get it to work.

I added everything to WordPress

wp_enqueue_script( 'ecp_admin_jquery', plugins_url('/ext/jquery-3.1.1.min.js' , __FILE__), array(), '3.1.1', false );
wp_enqueue_script( 'ecp_admin_bootstrap', plugins_url('/ext/bootstrap-3.3.7/js/bootstrap.min.js' , __FILE__), array(), '3.3.7', false );
wp_enqueue_script( 'ecp_admin_js', plugins_url('/js/script.js' , __FILE__), array(), '1.0', false );

Now i have the following example

<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="left" title="Tooltip on left">Tooltip on left</button>
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Tooltip on top">Tooltip on top</button>
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom">Tooltip on bottom</button>
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="right" title="Tooltip on right">Tooltip on right</button>

<script>
$(document).ready(function(){
    $('[data-toggle="tooltip"]').tooltip(); 
});
</script>

Works perfect. But when i move the

    $(document).ready(function(){
    $('[data-toggle="tooltip"]').tooltip(); 
});

to my script.js file it´s not working anymore. Does anybody know why?

0
wp_enqueue_script( 'ecp_admin_js', plugins_url('/js/script.js' , __FILE__), array(), '1.0', false );

Has to be:

wp_enqueue_script( 'ecp_admin_js', plugins_url('/js/script.js' , __FILE__), array(), '1.0', true );

Only if set to true the Script is added to the Footer (above closing body-Tag)!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.