Namespace with types and interfaces required by the AJAX upload manager.

Index

Type aliases

ElementReference

ElementReference: string | HTMLElement | Document | JQuery<HTMLElement> | JQuery<Document>

A reference to a DOM element. A string is interpreted as a CSS selector.

EventListener

EventListener: function

An event listener that takes a single event data object and should not return anything.

param

Event data provided by the event source.

Type declaration

    • (data: Data): void
    • Parameters

      • data: Data

      Returns void

FileItemState

Possible states of an AJAX upload item. An AJAX upload can be either:

  • pending - When the file is being uploaded to the server.
  • success - When the file was uploaded successfully.
  • failure - When the upload failed, such as due to a network error.
  • pendingRemoval - When the file is being removed from the server.

Properties

abortAll

abortAll: function
param

An optional container. When given, only abort all uploads within that element. Can be the upload element itself.

returns

A promise that resolves once all uploads are done.

Type declaration

addUpload

addUpload: function
param

One or multiple upload elements.

param

Data to upload.

param

Name of the file.

returns

An promise that resolves when alls uploads were added and uploaded successfully.

Type declaration

    • Parameters

      Returns Promise<void>

awaitAll

awaitAll: function
param

An optional container. When given, only waits until all uploads within that element have finished. Can be the upload element itself.

returns

A promise that resolves when all uploads are done.

Type declaration

disable

disable: function

Disables the AJAX upload feature. Aborts all pending uploads, removes all finished uploads, and removes all listeners so that no new AJAX uploads are started.

This must be called with the same container that was passed to AjaxUploadManager.enable.

param

Container with the uploads, usually the xm-form.

returns

A promise that resolves once all uploads are done.

Type declaration

enable

enable: function

Registers the appropriate listeners for all AJAX enabled upload fields inside the given container. This uses event delegation, so you can add elements inside the container dynamically after calling this function.

param

Container with the uploads, usually the xm-form.

Type declaration

events

events: object

An object with the event sources provided by the AJAX upload manager, such as when an upload begins, progresses, or was successful. You can subscribe or unsubscribe from these events.

Type declaration

getPendingUploadCount

getPendingUploadCount: function
param

An optional container. When given, only returns the count for the upload within that element. Can be the upload element itself.

returns

The number of pending uploads.

Type declaration

getUpload

getUpload: function
param

An optional container. When given, restricts the search to that element. Can be an upload element itself.

returns

The first upload item in the given container, or undefined when no such element exists.

Type declaration

getUploads

getUploads: function
param

An optional container. When given, only returns the uploads within that element. Can be an upload element itself.

returns

All upload items in the given container.

Type declaration

isAjaxUploadEnabled

isAjaxUploadEnabled: function

Checks whether the AJAX feature is enabled for a given upload element. When this returns false, other methods such as getUpload should not be used.

param

A container with the upload, or the upload element itself.

returns

true when the element is an upload element and the AJAX upload feature is enabled for that element, false otherwise.

Type declaration

removeUpload

removeUpload: function

Stops the upload if any upload is any progress, or removes the uploaded file if a file was uploaded.

param

One or multiple upload elements.

returns

A promise that resolves once all uploads were removed.

Type declaration

restoreUploads

restoreUploads: function
param

Container with the uploads, usually the xm-form.

Type declaration

stop

stop: function

Removes all listeners so that no new AJAX uploads are started, keep pending and finished uploads. Useful e.g. when you want to wait until all uploads have finished, but do not want to allow new uploads to be initiated.

This must be called with the same container that was passed to AjaxUploadManager.enable.

param

Container with the uploads, usually the xm-form.

Type declaration