This event is emitted when requests for an element were aborted.
This event is emitted on the element for which requests were aborted. If requests for entire layer were aborted, this event is emitted the layer's outmost element.
This would run code when an element or its descendants were aborted:
up.on(element, 'up:fragment:aborted', function(event) {
// element or its descendants were aborted
})
A more common use case is to run code when an element or one of its ancestors were aborted:
// Listen to all up:fragment:aborted events in case an ancestor
let off = up.on('up:fragment:aborted', function(event) {
if (event.target.contains(element)) {
// element or an ancestor was aborted
}
})
// Because we're registering a global event listener, we should
// clean up when `element` is destroyed.
up.destructor(element, off)
To simplify observing an element and its ancestors for aborted requests,
the function up.fragment.onAborted()
is provided. This allows us to shorten
the above code:
// Listen to all up:fragment:aborted events in case an ancestor
up.fragment.onAborted(element, function(event) {
// element or an ancestor was aborted
})
A string describing the reason for aborting this fragment.