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.Hide() issue #6

Closed IgorAndreGuerra closed 6 years ago

IgorAndreGuerra commented 6 years ago

anyone can help me? I need to hide Alert.ShowLoading after a few seconds?

If i try this code ShowLoading never ends...

function MyFunction(){ Alert.Hide(); alert("TEST"); } Alert.showLoading(); MyFunction();

Thanks!

PaulNieuwelaar commented 6 years ago

Hi, the function for hiding the alert is Alert.hide(); with a lowercase H. Also, with the current code you've got, it will hide the alert immediately without the user even seeing it. Usually this function is used with some async operation so the hide is done when the async callback is fired. If for some reason you just want to give the illusion of loading for a few seconds, you can use a timeout before hiding the alert; something like: setTimeout(Alert.hide, 2000); - Hope that helps, Paul

IgorAndreGuerra commented 6 years ago

Hi Paul, thank you very much for your reply...it works!! but if i want to show loading during 3 seconds and when finished show an OK Message with alert.show....? If i use setTimeout never shows loading... Best Regards!

PaulNieuwelaar commented 6 years ago

Hi, you can hard code the loading duration if you really need to. Just show the loading message first, then add a setTimeout to show another alert after 2 seconds etc. Note that it's usually not a good idea to hard code a loading duration. It would be better to just not show a loading spinner if the async task you're performing is completing instantly. If you're running sync tasks, it will lock the UI anyway, so you don't need a loading spinner for this either.

In any case, if you need to hard code the loading duration, you can do so like this:

Alert.showLoading();
setTimeout(function() {
    Alert.show("Success!", null, null, "SUCCESS", 250, 170);
}, 2000);