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

Callback cancel is missing #72

Open
andrevlima opened this issue Nov 29, 2017 · 1 comment
Open

Callback cancel is missing #72

andrevlima opened this issue Nov 29, 2017 · 1 comment

Comments

@andrevlima
Copy link

In some cases, to access resources that are wrapper maybe will want to make accessible in swal callback when it is triggered.
To do this, we use the known .bind()
swal({ title: "Are you sure?", text: "You will not be able to recover this imaginary file!", type: "warning", showCancelButton: true, confirmButtonClass: "btn-danger", confirmButtonText: "Yes, delete it!", cancelButtonText: "No, cancel plx!", closeOnConfirm: false, closeOnCancel: false }, (function(isConfirm) { debugger; if (isConfirm) { swal("Deleted!", "Your imaginary file has been deleted.", "success"); } else { swal("Cancelled", "Your imaginary file is safe :)", "error"); } }).bind());
But when used this technique, in case of cancel, the callback is never called, only when confirm.

@andrevlima
Copy link
Author

I have tracked the issue, it's caused by the check imposed in dev/modules/handle-click.js line 84, where it only calls the callback if it pass in a regex to ensure the presence of a parameter in function passed. In case the callback is a result of .bind() when passed to .toString() it miss all original function code and returns:
function () { [native code] }

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

1 participant