Edit this page

up.fragment up:fragment:aborted
DOM event

This feature is experimental. It may be changed or removed in a future version.

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.

To simplify working with this event, the function up.fragment.onAborted() is also provided.

Note

This event will not be emitted by the low-level up.network.abort() function.

Example

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 its ancestors were aborted
   }
})
// Because we're registering a global event listener, we should
// clean up when `element` is destroyed.
up.destructor(element, off)

Tip

To simplify observing an element and its ancestors for aborted requests, the function up.fragment.onAborted() is provided.


Event properties

event.target Element

The element for which requests were aborted.

event.reason string

A string describing the reason for aborting this fragment.

event.newLayer boolean

Whether the fragment was aborted by a new overlay opening.