4

It is redirecting to profile page when I click the close button. But it goes onclose event section and it should not refresh the page as It returns false but redirecting to profile page.

alertify.alert().setting({
                'title': 'Message',
                'label': 'Ok',
                'message': 'You have not yet enabled Appointment on your profile?',
                'onok': function () {
                    document.location.href = "/profile";
                },
                'onclose':function(e){
                   return false;//It should stop redirecting on profile page
                }
            }).show();

Error: When I click on Ok or Close(X) both events are firing.

Thanks.

Gufran Hasan
  • 8,910
  • 7
  • 38
  • 51

2 Answers2

2

Use

 'onclose':(e)=>{
    e.preventDefault();    //It will stop redirecting on profile page
    return false;//
}
AConsumer
  • 2,461
  • 2
  • 25
  • 33
2

As per the documentation of alertify this is the default functionality of alert onok event.

So when onok event is being called in alert It automatically calls onclose event to close the dialog.