Material: feat(dialog): support modifying options after the dialog has been opened

Created on 4 Mar 2015  路  12Comments  路  Source: angular/material

need some way to change options after showing a dialog. Looked into the source code, not sure how to access the options of $mdDialog.

Thanks

nice to have external contributor enhancement

Most helpful comment

I am going to reopen this enhancement request to signify that we're open for a PR from the community that implements this capability and includes unit tests.

All 12 comments

Which options were you looking to change?

Like clickOutsideToClose and escapeToClose

Are you saying the behavior should change after the dialog is open? Why can't those be set before it opens? Just trying to understand your request.

@marcysutton yes. i am trying to disable some behaviors of the dialog (like close the dialog by the escape key) when the dialog is handling an asynchronous call, and enable it after the http request's done.

+1

+1
I specifically look for this to be able to _change the closeTo node_ when cancelling a dialog. In my case I'd like to use the same node as openFrom.
Thx

+1
I'd like my dialog to create a new component in the dom, and closeTo that new element. Part of the problem is changing the closeTo after the dialog opened. (the other is to obtain the newly created element after a digest)

+1
My example - a dialog that adds something new to the page:
openFrom - from the button the user clicked (and if user cancels dialog it goes back there)
closeTo - the new element on the page (It the user visibly see to what they just added)

So if you could just make the closeTo directive binding '=?' - that's be great!

@kabalage @jmcpeak Did you find a trick to close on a newly added DOM element?

@ThomasBurleson I still have faith for this to be implemented...

I am going to reopen this enhancement request to signify that we're open for a PR from the community that implements this capability and includes unit tests.

Here is the principle of the work-around I used:

var dialogCloseEnabled = true;

function wrapMethod(method) {
  return function () {
    return dialogCloseEnabled ? method.apply($mdDialog, arguments) : false;
  };
}

$mdDialog.hide = wrapMethod($mdDialog.hide);
$mdDialog.cancel = wrapMethod($mdDialog.cancel);

dialogCloseEnabled = false;
// Escape/click on close/click outside has no effect
dialogCloseEnabled = true;
// Escape/click on close/click outside work again

Caution, this is a global approach, all modals will be linked to the globally set dialogCloseEnabled, so reset the setting on each modal destroy.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dona278 picture Dona278  路  3Comments

buzybee83 picture buzybee83  路  3Comments

robertmesserle picture robertmesserle  路  3Comments

pablorsk picture pablorsk  路  3Comments

chriseyhorn picture chriseyhorn  路  3Comments