Skip to content

Commit

Permalink
Fixed full-address-field.js loadScript()
Browse files Browse the repository at this point in the history
Fixed full-address-field.js loadScript()
  • Loading branch information
ZoomREI authored Nov 18, 2024
2 parents 967d24e + 39b1847 commit 1d5c295
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions wp-content/themes/chrisbuyshomes/src/js/full-address-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,28 +335,8 @@ function initAutocomplete() {
}

document.addEventListener("DOMContentLoaded", function () {
// Function to wait for Gravity Forms to be loaded
function waitForGform(callback) {
if (
typeof gform !== "undefined" &&
typeof gform.initializeOnLoaded !== "undefined"
) {
console.log("gform and gform.initializeOnLoaded are available.");
callback();
} else {
console.log("Waiting for gform to be defined...");
setTimeout(function () {
waitForGform(callback);
}, 100);
}
}

waitForGform(function () {
gform.initializeOnLoaded(function () {
loadScript(
"https://maps.googleapis.com/maps/api/js?key=AIzaSyCwwLF50kEF6wS1rTEqTDPfTXcSlF9REuI&libraries=places",
initAutocomplete
);
});
});
loadScript(
"https://maps.googleapis.com/maps/api/js?key=AIzaSyCwwLF50kEF6wS1rTEqTDPfTXcSlF9REuI&libraries=places",
initAutocomplete
);
});

0 comments on commit 1d5c295

Please sign in to comment.