Skip to main content

LazyBlockController

Purpose

AJAX load content, only when it comes into view, while showing a placeholder.

Actions

ActionPurpose
--

Targets

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

Classes

ClassPurposeDefault
---

Values

ValueTypeDescriptionDefault
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
lazy-block:successWhen the content is fetch successfullythe controller root element-
lazy-block:errorWhen the block fails to get a response from the endpointthe controller root element-
lazy-block:completeWhen the request finishes, regardless of success or failurethe controller root element-

Side Effects

None

How to Use

See Also

Async Block Controller Load Block Controller Poll Block Controller