JQuery close popup
I am using this jquery to show my popup,
//ResetPassword Popup display
$(document).ready(function () {
var passwordExpiredVal = $("#isPasswordExpired").html();
if (passwordExpiredVal == "True") {
$("#ResetPasswordModal").modal({
show: 'true'
});
};
});
I am using this jquery to pass the newly entered password to the ON CLICK controller action, after the save button is clicked. I want the popup to close.
//Reset Password submit
$(document).ready(function () {
$("#submitSave").on("click", function () {
var confirmPassword = $("#txtLgnPasswordConfirmReset").val();
var passwordReset = {
UserName: $("#txtLgnUsername").val(),
Password: $("#hdnOldPassword").val(),
NewPassword: $("#txtLgnPasswordReset").val()
}
if (passwordReset.NewPassword != confirmPassword) {
notifyMessage.showNotifyMessage('error', 'The passwords entered should match', false);
$("#txtLgnPasswordReset").val("");
$("#txtLgnPasswordConfirmReset").val("");
}
else {
$.ajax({
type: "POST",
url: "/Account/PasswordReset",
data: passwordReset,
success: function () {
$("#ResetPasswordModal").modal({
show: 'false'
});
},
error: function () {
alert('failure');
}
});
}
});
});
My jquery function doesn't help ...
success: function () {
$("#ResetPasswordModal").modal({
show: 'false'
});
},
Any ideas? Thanks in advance...
+3
source to share
1 answer
The code you are using unnecessarily initializes the modal value for this element.
Use modal('hide')
: Documents ,
success: function () {
$('#ResetPasswordModal').modal('hide');
},
If you want to use this again 'toggle'
would be the best option.
$('#ResetPasswordModal').modal('toggle')
0
source to share