0

I have a simple function to call on a specific page template. I'm calling it using this

<?php
    drupal_add_js("
        jQuery('.row).equalize();
    ","inline");
?>

and it's using an included js library called equalize.js. Which is included like so

<script type="text/javascript" src="mysiteurl/js/equalize.min.js"></script>

I receive 'jQuery(...).equalize is not a function'. but I'm assuming that's because

<script type="text/javascript" src="mysiteurl/js/equalize.min.js"></script> 

is being called after my inline js. This only needs to be called on one page. Is there a way to force it to run after the external js file is loaded? Or is there something else I'm missing?

Note: When I run the inline js after the page is loaded in the console in the inspector it works fine.

0

I was able to resolve this issue by encapsulating the inline js in a jQuery(document).ready function. Like so

<?php
drupal_add_js("
    jQuery(document).ready(function(){
        jQuery('.row').equalize();
    });
", "inline");
?>

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.