PaulNieuwelaar / alertjs

Dialog Builder allows you to create fully customisable dialogs and popups in Dynamics 365.
https://www.magnetismsolutions.com/our-products/alertjs-alert-popup-for-d365
Other
96 stars 38 forks source link

Alert.showWebResource custom button closing alert #26

Closed mikejramsey closed 5 years ago

mikejramsey commented 5 years ago

I'm using version 2.1.

I have a quote form with a custom ribbon button that calls Alert.showWebResource and loads a custom html resource with an ExtJs ViewPort and backing viewmodel.js... this all works perfectly fine. the viewport has a custom OK and Cancel button. What i cannot figure out is how do I simply close the Alert from the Cancel button callback, and close the alert in the success of the OK callback.

I've tried simply calling Alert.hide() in the cancel callback, but that doesn't "do" anything. the Alert is still displaying. I've tried getting the window with Alert.getIFrameWindow, and Alert.getCrmWindow, neither lets me actually hide the Alert itself.

Thanks in advance, Mike

mikejramsey commented 5 years ago

Stepping into the call for Alert.hide() and it is calling the hide function, however Alert._initialised is false. I can of course cheat and just call Alert.$("#alertJs-wrapper").hide(); in the cancel callback function, but that seems a little wrong to me. I'm curious as to why the _initialised is false in Alert.showWebResource??

image

image

ramakanta090 commented 5 years ago

@mikejramsey i am also trying use Alert.hide(); function to close my loading message( Alert.showLoading();) but its not working...I have also tried your approach but no luck

clemfernandez commented 5 years ago

I use parent.Alert.hide() from the Web resource and it does work fine.

However, both the default X and my custom Cancel button won't work on MS Edge, while they work fine on Chrome and Firefox.

PaulNieuwelaar commented 5 years ago

Hi Mike,

It looks like the alert.js web resource might be getting loaded multiple times, so the global variables are being reset. This would only really be an issue if an alert is displayed BEFORE the second web resource is loaded. Can you check if there are any other instances of the web resource being loaded?

Cheers Paul