Edit this page

API class up.Preview

Instances of up.Preview can describe temporary changes to a page.

You can use this to describe arbitrary loading state or implement optimistic rendering.

Previews are usually defined using up.preview() (lowercase) and then applied using the [up-preview] attribute or { preview } option. See Previews for an overview.


Features

All features

JS
up.Preview.prototype.addClass([element], className) stable

Temporarily adds a CSS class to an element.

JS
up.Preview.prototype.disable([element]) stable

Temporarily disables fields and buttons.

JS
up.Preview.prototype.ended stable

Whether this preview has ended.

JS
up.Preview.prototype.expiredResponse experimental

When revalidating a cache entry, this property is the cached response with expired content.

JS
up.Preview.prototype.fragment stable

The targeted Element that is being previewed.

JS
up.Preview.prototype.hide([element]) stable

Temporarily hides an element.

JS
up.Preview.prototype.hideContent([element]) experimental

Temporarily hides the children of an element.

JS
up.Preview.prototype.insert([reference], [position], newElement) stable

Temporarily inserts an element.

JS
up.Preview.prototype.layer stable

The layer that the previewed render pass is going to update.

JS
up.Preview.prototype.openLayer() experimental

Opens a temporary overlay.

JS
up.Preview.prototype.origin stable

The origin element that triggered this render pass.

JS
up.Preview.prototype.params stable

Form data for the request being previewed.

JS
up.Preview.prototype.removeClass([element], className) stable

Temporarily removes a CSS class from an element.

JS
up.Preview.prototype.renderOptions stable

The render options for this render pass.

JS
up.Preview.prototype.request stable

The request that is loading.

JS
up.Preview.prototype.revalidating experimental

Whether the previewed render pass is a revalidation an expired cache entry.

JS
up.Preview.prototype.run(nameOrFn, options) experimental

Runs another preview function.

JS
up.Preview.prototype.setAttrs([element], attributes) stable

Temporarily changes an element's attributes.

JS
up.Preview.prototype.setStyle([element], styles) stable

Temporarily sets inline CSS styles on an element.

JS
up.Preview.prototype.show([element]) stable

Temporarily shows a hidden element.

JS
up.Preview.prototype.showPlaceholder([element], newContent) experimental

Shows a temporary placeholder within an element.

JS
up.Preview.prototype.swapContent([element], newContent) experimental

Visually replaces the children of an element with new content for the duration of this preview.

JS
up.Preview.prototype.undo(undoFn) stable

Register a function that will revert this preview's effects when the preview ends.