JavaScript jQuery document ready will not work no matter how I write it jquery document ready shorthand,jquery document ready function,jquery document

I feel like this should be a simple thing to fix, but I just can't get it to work. I am running a jQuery store locator script with google maps. The script requires two javascript files, jquery, and the google maps api. Finally, it calls the actual function to run the locator. The files are as follows:

jlocator.min.js
jplist.min.js
jlocator.activate.js (this is where is put the document.ready script)
jquery
google api script

I have the locator working perfectly fine in a non-wordpress test site. But in Wordpress, the store locator script simply won't run. This is in my functions.php page

function my_map_scripts() {
    if ( is_page_template( 'template-project-map.php' ) ) {
        wp_enqueue_script(
            'jplist-custom-script',
            get_stylesheet_directory_uri() . '/js/jplist.min.js',
            array( 'jquery' )
        );
        wp_enqueue_script(
            'jlocator-custom-script',
            get_stylesheet_directory_uri() . '/js/jlocator.min.js',
            array( 'jquery' )
        );
        wp_enqueue_script(
            'jlocator-activate-script',
            get_stylesheet_directory_uri() . '/js/jlocator.activate.js',
            array( 'jquery' )
        );
        wp_enqueue_script(
                'google-maps',
                'https://maps.googleapis.com/maps/api/js'
            );
    }
}

add_action( 'wp_enqueue_scripts', 'my_map_scripts' );

I've enqueued the .js files, and they are loading fine. I put alerts in each file just to double-check. I also used wp_script_is, at one point, to make sure jQuery was running.

The problem seems to be in my document ready code. I am using the following:

jQuery(document).ready(function(){
    jQuery('#jlocator').jlocator();
});

This is doing nothing. I even tried putting an alert in to see if that would work:

jQuery(document).ready(function(){
    jQuery('#jlocator').jlocator();
    alert("activated");
});

Again, nothing. But if I remove this line:

jQuery('#jlocator').jlocator();

So that the codes reads:

jQuery(document).ready(function(){
        alert("activated");
    });

The alert fires fine. I also tried doing something like the code below just to see if it would work, but it didn't work, either. (.panel is a div on my page).

jQuery(document).ready(function(){
    jQuery('.panel').hide();
});

The above code worked fine in my non-Wordpress test site, though. It seems that anytime I use the following code to do something, it shuts everything else down.

jQuery('sometext')....

Is there something simple that I am missing here?

Also, I have tried writing the document ready as:

$(document).ready(function(){
    $('#jlocator').jlocator();
    alert("activated");
});

and

jQuery(document).ready(function($){
    $('#jlocator').jlocator();
    alert("activated");
});

but still nothing works. Any advice would be appreciated.

Answer:1

So I know about jQuery's .on() function to give dynamically added element's event handlers. E.g I've used it this way $(document).on("change",Items,function(){/*Code here*/}); But is there a way to ...

So I know about jQuery's .on() function to give dynamically added element's event handlers. E.g I've used it this way $(document).on("change",Items,function(){/*Code here*/}); But is there a way to ...

  1. jquery append html
  2. jquery append after
  3. jquery append before
  4. jquery append not working
  5. jquery append option to select
  6. jquery appendto
  7. jquery append to body
  8. jquery append class
  9. jquery append row to table
  10. jquery append text to div
  11. jquery append li to ul
  12. jquery append vs appendto
  13. jquery append to array
  14. jquery append first
  15. jquery append image
  16. jquery append multiple
  17. jquery append to textarea
  18. jquery append sibling
  19. jquery append to string
  20. jquery append to parent

On our website, we have a page where we have 5 images that are buttons. When you click each button, more detailed information appears using the onclick function. What we would like to do is pull the ...

On our website, we have a page where we have 5 images that are buttons. When you click each button, more detailed information appears using the onclick function. What we would like to do is pull the ...

  1. redirect from anchor
  2. redirect with anchor tag
  3. redirect with anchor link
  4. redirect to action from anchor tag

Our company is trying to link a page from a website that's using this code for the link: <a href="#" onclick="startBusinessIntent('guest','Retail','Craft/Hobby Vendor','Guest','BWPublic','Craft/...

Our company is trying to link a page from a website that's using this code for the link: <a href="#" onclick="startBusinessIntent('guest','Retail','Craft/Hobby Vendor','Guest','BWPublic','Craft/...

  1. unable to find page playstation store
  2. unable to find page with socket
  3. unable to find this page
  4. unable to find facebook page
  5. unable to find this page ps store
  6. unable to find this page psn
  7. xatom unable to find page with socket

I have a form element: <form name="formDate"> <input date-picker name="fundacao" ng-model-date="fTit.fundacao" required> </form> And the directive: app.directive('datePicker',...

I have a form element: <form name="formDate"> <input date-picker name="fundacao" ng-model-date="fTit.fundacao" required> </form> And the directive: app.directive('datePicker',...

  1. form not validating on submit
  2. form not validating on submit flask
  3. form not validating on submit django
  4. form not validating
  5. form not validating javascript
  6. form not validating angularjs
  7. form not validating asp.net mvc