Creating a usable Dialog module

Has anybody been able to create a usable modal dialog box using the Dialog module type?

I wanted to create a modal dialog box with just one button (a Close button), so I first tried creating a dialog module with chrome. This creates a dialog box with two buttons (Submit and Cancel). And while you can hide the submit button, you cannot hide the cancel button, which appears as a link. So you can’t have just a Submit button.
Next, I tried using a chrome-less dialog, and add my own buttons. This works, but the dialog, when opened, doesn’t get the focus, which means that you cannot use the keyboard to close the dialog (with Esc or Enter).

Has anyone been able to work around these limitations?

Hi @david2 ,

One thought is to (a) set the text of the cancel link to be “Close” by passing the parameter cancelText: "Close" in your dialog creation options and (b) hide the submit button by calling AP.dialog.getButton('submit').hide().

Regards,
Dugald

Hi @dmorrow , I’ve done exactly that, but you end up with only a “link style” button, which is very confusing for users. Unfortunately, you can’t make the cancel button look like a regular button, let alone the primary button.
Which is why I tried creating a chrome-less dialog instead.

1 Like