I have an .on('click', function())
that is calling another function
$('.controls a[data-attr="editEmailAddress"]').on('click', function (e) {
e.preventDefault();
if ($(this).hasClass("btn-primary")) {
updateEmailAddress();
} else {
hideSuccess();
}
$(this).addClass("btn-primary");
$(this).find('i').addClass("icon-white icon-edit").addClass('icon-ok');
$(this).siblings('input[type=text]').attr('disabled', false);
});
The function does some standard validation and if it is valid it's is supposed to remove the classes btn-primary
among some other things.
function updateEmailAddress() {
// Clear the error div of any previous errors
$('#validationSummary').hide().empty();
var isValid = true;
// Must Enter Email Address
var emailEntered = $('#txtEmailAddress').val();
if (!$.trim(emailEntered).length) {
$('#validationSummary').append('Email address required').fadeIn();
isValid = false;
}
else {
// If Email Entered verify that it is a valid email address
if (!validateEmail(emailEntered)) {
$('#validationSummary').append('Enter valid email address.').fadeIn();
isValid = false;
}
}
if (isValid) {
// Change state of edit icon
$('#lnkEditEmailAddress').removeClass("btn-primary");
$('#lnkEditEmailAddress').find('i').addClass("icon-white icon-edit").addClass('icon-ok');
$('#lnkEditEmailAddress').siblings('input[type=text]').removeAttr('disabled', true); }
}
Here is a working jsfiddle
Can someone identify what changes would need to be made to get the input/image back to it's original disabled state? Would this have something to do with the classes not being in the DOM when the page loads?
There is obviously a web-method that won't be found causing an error