0

I am using a jquery plugin for alerts given below:-

 function alertWithNewWindow(title, content, icon, newWindow) {
            $.alert.open({
                title: title,
                content: content,                   
                icon: icon,                   
                draggable: true
            });
        }

I want to add a callback to above function so that when user click on "ok" button of alert-box then page will redirect to the given path.

  $(window.location.replace(newWindow));

I have tried below code but its not redirecting.

   function alertWithNewWindow(title, content, icon, newWindow) {
            $.alert.open({
                title: title,
                content: content,                
                icon: icon,                  
                draggable: true
            }, function () {
                $(window.location.replace(newWindow));
            }
            );
        }

1 Answer 1

1

I am guessing you are using this plugin.

After reading the Callback doc section I think this code should work out for you:

  function alertWithNewWindow(title, content, icon, newWindow) {
            $.alert.open({
                title: title,
                content: content,
                align: 'center',
                icon: icon,
                maxHeight: 160,
                draggable: true,
                callback: function(){
                       $(window.location.replace(newWindow));
                   } 
            );
        }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.