Edit this page

up.Preview up.Preview.prototype.showPlaceholder([element], newContent)
Instance method

This feature is experimental. Please share your experiences so we know what to keep or change.

Shows a temporary placeholder within an element.

The element's existing children will be hidden for the duration of this preview. When the preview ends, the placeholder will be removed and the element's original children are shown again.

If the previewed render pass opens a new overlay, the placeholder will be shown temporary overlay with the same visual style and open animation.

Example

This preview below shows a .skeleton element within the targeted fragment. Other children of the

up.preview('skeleton', function(preview) {
  preview.showPlaceholder('<span class=".skeleton">...</span>')
})

You may also clone a template:

up.preview('skeleton', function(preview) {
  preview.showPlaceholder('#skeleton-template')
})

To show the placeholder within another element, pass it as a first reference argument:

up.preview('showPlaceholder', function(preview) {
  preview.swapContent('body', '#skeleton-template')
})

Parameters

[element=this.fragment] Element|string optional

The element within which to show a placeholder, or its selector.

newContent Element|string

The placeholder to insert.

You may pass an Element, a CSS selector or a snippet of HTML.

If the given element is a template, it will be cloned before insertion.