Load javascript from external file with dependencies
-
I’m trying to use javascript plugins that need jquery as a dependency. I tried almost everything and I can’t make it run. What I’ve done so far is:
– Load scripts in themes’ header.php (In header.php. Maskedinput and meiomask are the plugins I’m trying to use):<script src="/JavaScript/jquery.js" type="text/javascript"></script> <script src="/JavaScript/maskedinput.js" type="text/javascript"></script> <script src="/JavaScript/meiomask.js" type="text/javascript"></script>
– Enqueue/register plugins (still in header.php):
<?php wp_enqueue_script('handle_jquery', 'https://my_ip/JavaScript/jquery.js'); wp_register_script('handle_meiomask', 'https://my_ip/JavaScript/meiomask.js', array('handle_jquery')); wp_register_script('handle_maskedinput', 'https://my_ip/JavaScript/maskedinput.js', array('handle_jquery')); ?>
– Call function (in header.php, as required by plugin maskedinput):
<script type="text/javascript"> $(function() { $('input[@name=htmlDataInicio]').mask('99/99/9999'); }); </script> <script type="text/javascript"> jQuery(function($){ $("htmlDataInicio").mask("99/99/9999"); }); </script> <script type="text/javascript"> jQuery(function($){ $("#htmlDataInicio").mask("99/99/9999"); }); </script>
– Put alt=”wanted_mask” (as required by meiomask plugin):
<p><b>Recursos: </b><input type="text" id="decimal" name="some_name" alt="decimal" /></p>
And the plugins don’t work.
Any help appreciated. Thanks.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Load javascript from external file with dependencies’ is closed to new replies.