Modal dialog 'cancel' button cannot be disabled using AP.dialog.getButton('cancel').disable()

Hi there,

We make use of a modal dialog to submit some information to our apps that involve copying and creating spaces and page trees.

And as such we would like to disable some buttons during the processing step.

According to the JavaScript API, users can make use of AP.dialog.getButton() to access various buttons on the page. This works fine for the submit buttona and cancel button as can be seen below:

submitButton
cancelButton

However when I attempt to make use of AP.dialog.getButton().disable(), it only works for the submit button and not the cancel button:

AP.dialog.getButton('submit').disable();
AP.dialog.getButton('cancel').disable();

The above code only disables the submit button and not the cancel button:

cancelButtonNotDisabled

Has anyone else managed to successfully disable the cancel button?

Kind regards,
Dirk de Klerk
EPS software Engineer

If it turns out that you can’t disable the cancel button (I don’t know whether you can or not!), I would assume it’s because we want to leave the user with a way of closing the dialog.

Why do you want to prevent the user from closing the dialog the expected way?

Hi @eps.dev.instance,
DoesAP.dialog.getButton('cancel').toggle() do anything?
Regards,
Dugald

Can’t speak to @eps.dev.instance’s needs but we’re looking into something similar since we’re needing the dialog component to be shown while we’re fetching data. We’ve got a workaround but hiding the button like we can do cancel would be nice.

Hi @dmorrow,

I have attempted to use toggle as well? with no effect?

Kind regards,
Dirk

Hi @huw,

Agree that there needs to be an expected way to close a dialog. However we do perform sensitive operations during the submit phase so would like to disable the cancel button for that period of time.

The snippet above infers that I can get the cancel button using getButton(). If I cannot call any functions on the returned object, it feels a bit redundant.

Perhaps the documentation can be updated to reflect that fact then?

KInd regards,

Dirk

Hi @eps.dev.instance and @danielwester, if you take a look at ACJS-253, it seems the prevention of the disabling of the cancel button was deliberate, but there is no documented reason. I’ve added a comment to see if we can understand why.

2 Likes

@mstaas posted a workaround in ACJS-253 whereby you create a chromeless dialog so that the dialog doesn’t include the cancel button.

AP.dialog.create({
  "size": "medium",
  "chrome": false,
  "header": "header"
});
1 Like

Hi @dmorrow, Thank you for providing me with feedback as well as an alternative solution. It is really appreciated.

Really excellent support from your side.

Kind regards,

Dirk

1 Like