Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect after pressing OK , in the Confirm alert. #319

Closed
azlannohara opened this issue Mar 23, 2015 · 8 comments
Closed

Redirect after pressing OK , in the Confirm alert. #319

azlannohara opened this issue Mar 23, 2015 · 8 comments

Comments

@azlannohara
Copy link

Hello all. I been using the confirm alert.

swal({   
title: "Are you sure?",   
text: "You will not be able to recover this imaginary file!",   
type: "warning",   
showCancelButton: true,   
confirmButtonColor: "#DD6B55",   
confirmButtonText: "Yes, delete it!",   
closeOnConfirm: false 
}, 
function()
{   
swal("Deleted!", "Your imaginary file has been deleted.", "success"); });

Can I redirect/reload page after the user click OK on ("Deleted!", "Your imaginary file has been deleted.", "success") ?

@masteradhoc
Copy link

Maybe this could help you..
Follow an external link at https://www.ludu.co/lesson/how-to-use-sweetalert

@azlannohara
Copy link
Author

Alright. Thanks!

On Wed, Mar 25, 2015 at 4:36 PM, Brian notifications@github.com wrote:

Maybe this could help you..
Follow an external link at
https://www.ludu.co/lesson/how-to-use-sweetalert


Reply to this email directly or view it on GitHub
#319 (comment).

@guyschlider
Copy link

Passing another callback to the second swal seems to be a problem. have you found a solution?

@t4t5
Copy link
Owner

t4t5 commented Apr 1, 2015

I'll close this since it's not an issue.

@t4t5 t4t5 closed this as completed Apr 1, 2015
@guyschlider
Copy link

@t4t5 - Can the second swal function confirm have a callback function? doesn't seem to work to me.

@introwit
Copy link

introwit commented Jun 10, 2016

@t4t5 Hey thanks for SweetAlert :) I found the solution for this issue and sharing it below.
I know its old but i found the solution so i hope it helps anyone.

@mp3il @azlannohara @masteradhoc The problem is the shorthand in the closure. You can do the required(Reload after clicking on "Okay" that appears after successful deletion) by using the below code:

   `$('a.delete-member').click(function() {
    var memberId = $(this).attr("data-member-id");
    deleteMember(memberId);
  });

  function deleteMember(memberId) {
    swal({
      title: "Are you sure?", 
      text: "Are you sure that you want to delete this member?", 
      type: "warning",
      showCancelButton: true,
      showLoaderOnConfirm: true,
      closeOnConfirm: false,
      confirmButtonText: "Yes, delete it!",
      confirmButtonColor: "#ec6c62"
    }, function() {
      $.ajax({
        url:  "/members/" + memberId + "/archive",
        type: "POST"
      })
      .done(function(data) {
        swal({
            title: "Deleted", 
            text: "Member has been successfully deleted", 
            type: "success"
        },function() {
            location.reload();
        });
      })
      .error(function(data) {
        swal("Oops", "We couldn't connect to the server!", "error");
      });
    });
  }`

@Hajmahdikahsan
Copy link

Hajmahdikahsan commented Nov 25, 2017

I used this code but Show error
VM1355:23 POST http://localhost:7100/Forces/Delete/5 500 (Internal Server Error)

function Delete(id) {
swal({
title: "Are you sure?",
text: "Are you sure that you want to delete this member?",
type: "warning",
showCancelButton: true,
showLoaderOnConfirm: true,
closeOnConfirm: false,
confirmButtonText: "Yes, delete it!",
confirmButtonColor: "#ec6c62"
}, function() {
$.ajax({
url: "/Forces/Delete/"+id,
type: "POST"
})
.done(function(data) {
swal({
title: "Deleted",
text: "Member has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
});
}

@shohelic
Copy link

@introwit it's working and grate. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants