htmx
htmx copied to clipboard
[backport][v1] Add capabilities to cancel an hx-trigger polling
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 (
masterfor website changes,devfor 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
Any progress here?