Home / Documentation / Address Autocomplete / Trigger Address Autocomplete on hidden elements

Trigger Address Autocomplete on hidden elements

Address Autocomplete now comes with a Delay option which accomplishes this same thing with a simple setting instead of needing custom code.

By default, Address Autocomplete attaches itself to form fields on the page after the initial page load which requires the form fields to be present and visible on initial page load. If your address fields are in a popup or hidden behind conditional form fields, you will need to add some custom code to trigger the address autocomplete once the fields are visible.

The below code is an example and you will need to adjust it for your specific needs.

jQuery( '#element' ).on( 'change' , function () {
    setTimeout( 'wps_aa', 500 );
} );

This code is listening for a change event to be fired for an element, waiting half a second (500ms) so any hidden elements have a moment to become visible, then triggering the address autocomplete to attach itself to your fields.

Another common example is when using an Elementor popup. Here is how to trigger Address Autocomplete after a popup is opened:

jQuery( document ).on( 'elementor/popup/show', () => {
	wps_aa();
} );

Premium users can contact support for additional help.