I'm trying to prevent double submission using the enter key on my form, but I can't seem to re-enable the keypress after the data has been submitted. Here's a part of my code:
$(".adauga-clasa").submit(function() {
var adaugaClasa = $('input[type=text]', this);
adaugaClasa.keypress(function(event) { if (event.keyCode == '13') { return false; } });
$.ajax({
type: "POST",
url: "/clase/do-add",
data: dataString,
dataType: "json",
success: function(data) {
// this doesn't work
adaugaClasa.keypress(function(event) { if (event.keyCode == '13') { return true; } });
}
});