You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021
  1. import * as htmx from 'htmx.org';
  2. import {showErrorToast} from './modules/toast.js';
  3. // https://github.com/bigskysoftware/idiomorph#htmx
  4. import 'idiomorph/dist/idiomorph-ext.js';
  5. // https://htmx.org/reference/#config
  6. htmx.config.requestClass = 'is-loading';
  7. htmx.config.scrollIntoViewOnBoost = false;
  8. // https://htmx.org/events/#htmx:sendError
  9. document.body.addEventListener('htmx:sendError', (event) => {
  10. // TODO: add translations
  11. showErrorToast(`Network error when calling ${event.detail.requestConfig.path}`);
  12. });
  13. // https://htmx.org/events/#htmx:responseError
  14. document.body.addEventListener('htmx:responseError', (event) => {
  15. // TODO: add translations
  16. showErrorToast(`Error ${event.detail.xhr.status} when calling ${event.detail.requestConfig.path}`);
  17. });