javascriptalertifyalertifyjs

When clicks on close button it should stop redirecting using alertify?


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.


Solution

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