Skip to content

0.2.0

Choose a tag to compare

@jonnitto jonnitto released this 06 Feb 21:59
· 19 commits to main since this release
8781cba

Javascript Event to initalize maps

If you dispatch an event with the name jonnitto-maps:init, the maps will be initalized. This is useful in when you
work with AJAX request. The event listener is attached to the window object.

If you want, for example, use it togheter with turbo

document.addEventListener('turbo:load', ({ detail }) => {
  // It is not the first load
  if (detail.timing?.visitStart) {
    window.dispatchEvent(new Event('jonnitto-maps:init'));
  }
});

or with Alpine AJAX:

window.addEventListener('ajax:success', () => {
  window.dispatchEvent(new Event('jonnitto-maps:init'));
});

Full Changelog: 0.1.4...0.2.0