select-your-own-seat

Expand History Expand History
Collapse History Collapse History

Dynamically Hide and Show Loading Spinner

Add the loadingOverlay target to the seats controller, and route the document-wide global events named turbolinks:request-start and turbolinks:load to the seats#loadingStarted and seats#loadingFinished actions respectively.

When handling turbolinks:request-start and turbolinks:load events, only hide and show the loading indicator when we’re discarding our map element, since it’s persisted across navigations when the data-turbolinks-permanent attribute is present.

The CSS class that visually indicates a loading state is .is-loading. This class is passed as the [data-seats-loading-class] attribute on the [data-controller="seats"] element in the seats/index template. Once declared as such, that value is available through Stimulus’ Data Maps interface.

Desktop

loading-spinner-on-nav