Skip to main content

PollBlockController

Purpose

AJAX load/refresh content periodically, at a configurable interval.

Actions

ActionPurpose
--

Targets

TargetPurposeDefault
replace (Optional)The element to replace when the fetch request succeedthe controller root element

Classes

ClassPurposeDefault
---

Values

ValueTypeDescriptionDefault
secondsStringThe number of seconds between each refresh. When the time has elapsed, the controller will send a Fetch request for the content.-
endpointStringThe URL to fetch content from-
errorMessage (Optional)StringThe error message to display when the remote content fails to loadThis content failed to load
selector (Optional)StringThe CSS selector to use to extract the desired element(s) from the returned HTML responseEmpty. The entire HTML response will be loaded
maxRetries (Optional)NumberHow many times the controller should retry fetching the content in the event of network errors or bad responses1

Events

EventWhenDispatched onevent.detail
poll-block:successWhen the content is fetch successfullythe controller root element-
poll-block:errorWhen the block fails to get a response from the endpointthe controller root element-
poll-block:completeWhen the request finishes, regardless of success or failurethe controller root element-

Side Effects

None

How to Use

See Also

Async Block Controller Lazy Block Controller Load Block Controller