LOEFD
Join ServerLeague of Extraordinary FoundryVTT Developers
development-basics
Dialog shennanegins
TIL the button callbacks for
Dialog.prompt
and Dialog.confirm
can be asynchronous.const foo = async () => {
const response = await Dialog.prompt({
title: "Confirmation Title",
content: "Are you sure about that?",
callback: async (html) => { return 'foo' },
});
console.log('responded', response); // 'foo' when the button is pressed
};
foo()
const refrain = () => Dialog.prompt({
content: "It just goes on and on my friends.",
callback: chorus
});
const chorus = () => Dialog.prompt({
content: "This is the song that never ends.",
callback: refrain
});
chorus();
Can you pass the html between the two as well?
Yeah! the argument of the callback is the
html
const annoying = () => Dialog.confirm({
content: "Press yes or I come back.",
no: annoying
});
annoying();
hard to see what's happening here, but each one is actually adding one to the nested dom stack.
function outerHTML(node){
return node.outerHTML || new XMLSerializer().serializeToString(node);
}
const inception = (html) => Dialog.prompt({
content: html[0] instanceof Node ? outerHTML(html[0]) : html[0],
callback: inception
});
inception(["We have to go deeper."]);