$(document).ready( function(){ $("form").submit(function() { confirmation("Вы действительно хотите удалить аккаунт?", "Да", "Отмена", function (result) { if(result == true) $("form").submit(); //return true не работает }); return false; }) }); There is a form, on it a button to delete an account, pressing the button pops up confirming the deletion, and then the form should be sent, but no .. confirmation callback function that returns yes or no, how to change the code without confirming the confirmation function? UPD:
function confirmation(message, ok, cancel, callback) { if (!$('#confirmation').length) { var string = 'html'; $('<div/>').attr('id', 'confirmation').css("display", "none").html(string).appendTo('body'); } var result; $.fancybox($('#confirmation'), { modal : true, autoSize: true, beforeShow: function() { $("#confirmation-message").text(message); $("#confirmation-btn-ok").unbind("click").bind("click", function() { result = true; $.fancybox.close(); return false; }) $("#confirmation-btn-cancel").unbind("click").bind("click", function() { result = false; $.fancybox.close(); return false; }) }, afterClose: function() { callback.call(this, result); } }); }