Skip to content

Commit

Permalink
Add browser event to refresh JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjitse-E committed May 16, 2024
1 parent 703bc56 commit 3251681
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ There is no disable/enable configuration. To disable the module, simply remove t
- [ ] Autocomplete for adding a new address as a logged in user (see [#5](https://github.com/Vendic/hyva-checkout-google-address-autocomplete/issues/5))
- [x] Works on the company field and street 0. To add additonal fields, check `\Vendic\HyvaCheckoutGoogleAddressAutocomplete\ViewModel\AutoCompleteSelectors`
- [x] Housenumber validation to check if the housenumber contains digits.
- [x] Reload autocomplete JS by triggering a browser event named `re-init-google-autocomplete`. This can be useful when you are removing/adding fields dynamically.

## Customizations
### Field mapping
Expand Down
3 changes: 3 additions & 0 deletions view/frontend/templates/checkout/google-autocomplete-js.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ if (!$apiKey) {
// Re-init autocomplete when billing as shipping is toggled
window.addEventListener('billing-as-shipping-toggled', () => { reInitAutocomplete()} );

// Allow for re-initialization of the Google Autocomplete functionality via external scripts
window.addEventListener('re-init-google-autocomplete', () => { reInitAutocomplete() });

// Wait for Google Maps JS callback to add autocomplete to specified inputs
document.addEventListener('google_maps_js_loaded', () => { addAutocompleteToInputs(); });

Expand Down

0 comments on commit 3251681

Please sign in to comment.