What I have been attempting to implement is a function that will be called to trigger an error animation using the .one(); function in jQuery. When I validate a form and it fails, I call the triggerError function in my code, sending it the element that needs to have the animation applied to it. The .error animation class is correctly applied, but the .one(); function does not recognize that the animation has completed in order to remove the .error class.
Here is the Javascript that listens for the click and attempts to apply and remove the animation class:
$('#search').on('click', function(e) {
if ($(this).val() === "") {
triggerError($(this).parent());
return;
}
});
function triggerError(input) {
input.addClass('error');
input.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function() {
input.removeClass('error');
});
}
I've also created a Codepen to illustrate this error on an input.
Thanks in advance for any assistance!