I have an instance where I would like to define logic flow based on whether a dialog box is open.
My clunky method at first attempt was setting a boolean variable true when opened and false when closed.
Is there a built in flag in js that would give me the status of a dialog box based on its id?
Thanks,
David
@jdavidpugh That is unfortunately not currently possible, but an excellent idea for our roadmap. I will submit the idea on your behalf and hopefully this is something we can add in a future release.
For now your work around seems reasonable. Consider creating a helper function that both shows the dialog and sets the flag. Something like this.
var dialogStatus = {};
function showDialog(dialogID) {
dialogStatus[dialogID] = true; // flags which dialog is showing
component.dialog({id: dialogID}).show();
}
function hideDialog(dialogID) {
dialogStatus[dialogID] = null; // clears flags
component.dialog({id: dialogID}).hide();
}
If you do take this route you will need to ensure that every dialog has the auto-hide="false"
flag set to make sure you control when the dialog is closed and can clear the flag accordingly
@tielman That was my original solution. The end game was modification of Realwear Voice Commands for say a delete confirmation dialog with single syllable “Yes”/“No” commands. My final solution was to actually change the Journey.voice command registration with the helper functions that open and close the dialog.
function buttonDeleteDialog() {
dialogDeleteCommands();
component.dialog({ id: "deleteitem" }).show();
}
function buttonPressDelete() {
view.add_photos.destroyAll();
view.selected_item.destroy();
registerCommands();
navigate.dismiss();
}
function buttonDeleteCancel() {
registerCommands();
component.dialog({ id: "deleteitem" }).hide();
}
@tielman While we are asking… an on-open, on-close trigger would probably be really nice.
That may actually be more useful than a static flag.
<dialog on-open="$:openfunction()" on-close="$:closefunction()">
1 Like