htmx icon indicating copy to clipboard operation
htmx copied to clipboard

[backport][v1] Add capabilities to cancel an hx-trigger polling

Open xhaggi opened this issue 1 year ago • 1 comments

Description

This adds three ways to cancel an hx-trigger polling. The first is a new configuration option htmx.config.cancelPollingOnError, which can be activated to cancel an hx-trigger polling in case of an error (status not 200). The second is a new event htmx:cancelPolling and the third is a new response header HX-Cancel-Polling.

document.addEventListener('htmx:cancelPolling', function(evt) {
    if (evt.detail.xhr.status !== 200) {
      evt.preventDefault();
    }
});

Corresponding issue: #2489

Testing

Unit tests added.

Checklist

  • [x] I have read the contribution guidelines
  • [x] I have targeted this PR against the correct branch (master for website changes, dev for source changes)
  • [x] This is either a bugfix, a documentation update, or a new feature that has been explicitly approved via an issue
  • [x] I ran the test suite locally (npm run test) and verified that it succeeded

xhaggi avatar May 29 '24 14:05 xhaggi

Any progress here?

gerbil avatar Aug 14 '24 13:08 gerbil