I want to use these dialog-samples in my project. I downloaded js and css files, packed into zip and uploaded as static-resource. Trying to use it, I receive ReferenceError: Dialog is not defined. How can I solve this?
sharingSettings.js
import dialog from '@salesforce/resourceUrl/dialog';
export default class SharingSettings extends LightningElement {
async connectedCallback() {
this.loadScripts();
}
async loadScripts() {
try {
await loadScript(this, dialog + '/dialog.js');
console.log('scripts loaded');
} catch (error) {
console.error(error);
throw new Error('error loading scripts ', error)
}
}
async handleShowAlert() {
await Dialog.alert(
'Message',
{ok: 'OK'}
);
}
}
dialog.js
let Dialog = (() => {
// Ommited for brevity
// expose the external API to the caller/user of this code
return {
alert(message, opts, cb) {
return new AlertDialog(message, opts, cb).open();
},
confirm(message, opts, cb) {
return new ConfirmDialog(message, opts, cb).open();
},
prompt(message, opts, cb, defaultValue) {
return new PromptDialog(message, opts, cb, defaultValue).open();
}
}
})();
let Dialog =
towindow.Dialog =
did the work, thank you :)