Skip to main content

Modal Class

The Modal Class is the base class for our Modal Service

To create a modal class create a new class and extend it to subclass from digideck.Modal this class can now be used in digideckCore.modalService

    export default class FavoritesFormModal extends digideckCore.Modal {
constructor() {
super();
}

connectedCallback() {
super.connectedCallback();

// on initialization callback function
}

// list of attributes to watch for changes in value
static get observedAttributes() { return ['options']; }

// invoked when an observed attribute has a change in value
attributeChangedCallback(attributeName, oldValue, newValue) {
if (newValue === oldValue) return;

if(attributeName === 'options') {
this.options = JSON.parse(decodeURI(newValue));
}
}
}

Modal

The Modal object is what is returned by the Modal Service.

Methods

openModal(onCloseCallback)

Description

  • displays the created modal by adding 'active' class on the modal.

Return Value: String

Code Example

    modalInstance.openModal(onCloseCallback);

closeModal(data)

Description

  • hides the created modal by removing the 'active' class. The callback function provided by openModal is invoked, and is passed data which can be of any value you choose.

Return Value: null

Code Example

    modalInstance.closeModal(modalData);