Commit 716cc5ef by Dányi Bence

webui: better template name checking (ajax)

parent 5685b1c7
...@@ -69,26 +69,37 @@ ...@@ -69,26 +69,37 @@
$("#new-template-size-summary-" + v).show(); $("#new-template-size-summary-" + v).show();
}); });
$('#new-template-step-2 nav .next').attr("disabled", "disabled"); $('#new-template-step-2 nav .next').attr("disabled", "disabled");
$("#new-template-name").change(function(e){ $("#new-template-name").keyup(function(){
var s = $(this).val(); var timer;
$.ajax({ return function(e){
'type': 'GET', var self=this;
'url': '/ajax/template_name_unique/' + s, clearTimeout(timer);
'success': function(data, b, c) { console.log('asdasdasdasd');
if (s != $("#new-template-name").val()) { timer=setTimeout(function(){
return True; console.log('asd');
} var s = $(self).val();
if (data == "True") { $.ajax({
$('#new-template-name').removeClass("error"); 'type': 'GET',
$('#new-template-step-2 nav .next').removeAttr("disabled"); 'url': '/ajax/template_name_unique/' + s,
} 'success': function(data, b, c) {
else { if (s != $("#new-template-name").val()) {
$('#new-template-name').addClass("error"); return true;
$('#new-template-step-2 nav .next').attr("disabled", "disabled"); }
} if (data == "True") {
} $('#new-template-name').removeClass("error");
}); $('#new-template-step-2 nav .next').removeAttr("disabled");
}); $('#new-template-name').removeProp("title");
}
else {
$('#new-template-name').addClass("error");
$('#new-template-step-2 nav .next').attr("disabled", "disabled");
$('#new-template-name').prop("title", gettext('Please choose a different name.'));
}
}
});
}, 1000)
}
}());
}) })
</script> </script>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment