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;
return function(e){
var self=this;
clearTimeout(timer);
console.log('asdasdasdasd');
timer=setTimeout(function(){
console.log('asd');
var s = $(self).val();
$.ajax({ $.ajax({
'type': 'GET', 'type': 'GET',
'url': '/ajax/template_name_unique/' + s, 'url': '/ajax/template_name_unique/' + s,
'success': function(data, b, c) { 'success': function(data, b, c) {
if (s != $("#new-template-name").val()) { if (s != $("#new-template-name").val()) {
return True; return true;
} }
if (data == "True") { if (data == "True") {
$('#new-template-name').removeClass("error"); $('#new-template-name').removeClass("error");
$('#new-template-step-2 nav .next').removeAttr("disabled"); $('#new-template-step-2 nav .next').removeAttr("disabled");
$('#new-template-name').removeProp("title");
} }
else { else {
$('#new-template-name').addClass("error"); $('#new-template-name').addClass("error");
$('#new-template-step-2 nav .next').attr("disabled", "disabled"); $('#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