• 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)
  • <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/Javascript/jquery.js"></script>

    does it work any better like this to load them?

    (assuming the scripts are in a Javascript folder, in your theme)

    Thread Starter jorge_ricardo

    (@jorge_ricardo)

    First of all, thanks RVoodoo.
    But my problem is not loading the scripts. I’ve loaded them and tested with a simple button and an alert message and it worked fine. So I guess they are loading. My problem is that maskedinput and meiomask plugins need jquery as a dependency. So my problem is wp_enqueue/wp_register functions (or that’s what I think, at least).
    So, anyone knows how to make dependencies work?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Load javascript from external file with dependencies’ is closed to new replies.