I have a javascript file with the following code (for test):
$(document).ready(function() {
alert(1);
});
I try to include this file in my form, but the alert doesn't show up. I tried enqueuing the file as follows:
add_action('gform_enqueue_scripts',"my_gform_enqueue_scripts", 10, 2);
function my_gform_enqueue_scripts($form, $is_ajax=true){
wp_enqueue_script("auto-complete", get_bloginfo('template_directory').'/js/form.js', array(), '1',true);
}
but that doesn't work. I also tried adding a
<script>
tag to the top of my page template (I'm using a special page template for my form):
<script src="<?php get_bloginfo('template_directory')?>/js/form.js" type="text/javascript"></script>
but that doesn't work either. What am I doing wrong?
The funny thing is that in both cases, the alert doesn't show up on the first time I load the form (the form is loaded via thickbox), but on the following times the alert does work