material icon indicating copy to clipboard operation
material copied to clipboard

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

Open hitigon opened this issue 11 years ago • 12 comments

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

hitigon avatar Mar 04 '15 18:03 hitigon

Which options were you looking to change?

dmackerman avatar Mar 04 '15 22:03 dmackerman

Like clickOutsideToClose and escapeToClose

hitigon avatar Mar 04 '15 22:03 hitigon

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 avatar Mar 11 '15 18:03 marcysutton

@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.

hitigon avatar Mar 11 '15 19:03 hitigon

+1

thunghan avatar Oct 30 '15 06:10 thunghan

+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

hannesAxiell avatar Nov 03 '15 16:11 hannesAxiell

+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)

kabalage avatar Dec 09 '15 10:12 kabalage

+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!

jmcpeak avatar Feb 07 '16 21:02 jmcpeak

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

nicmae avatar Jan 26 '17 07:01 nicmae

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

fbricenho avatar Aug 24 '18 09:08 fbricenho

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.

Splaktar avatar Aug 25 '18 00:08 Splaktar

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.

kylekatarnls avatar Mar 06 '19 10:03 kylekatarnls