This feature is experimental. Please share your experiences so we know what to keep or change.
Visually replaces the children of an element with new content for the duration of this preview.
The visual effect is achieved by hidden existing children and inserting a new element as the only visible child. When the preview ends all changes will ber reverted.
Tip
To visually remove elements during a preview, prefer hiding over detaching. See Prefer additive changes.
This preview (visually) replaces the children of the targeted fragment
with a .spinner
element:
up.preview('spinner', function(preview) {
preview.swapContent('<span class="spinner">Please wait...</span>')
})
To swap the content of another element, pass it as a first reference argument:
up.preview('spinner', function(preview) {
preview.swapContent('body', '<span class="spinner">Please wait...</span>')
})
The element or selector to visually swap children off.
If omitted, the children of the targeted fragment will be swapped.