Tweaked the customer similar JS. Now only fires if 3 chars entered

This commit is contained in:
Karl Cordes 2010-03-16 14:51:08 +11:00
parent 625eb8e42a
commit 150cbc7079

View file

@ -9,37 +9,44 @@
$(function() { $(function() {
$("#dialog").hide(); $("#dialog").hide();
$("#customerName").change(function () {
$("#dialog").dialog('close'); //Remove any previously opened dialogs /*If the user has entered 3 or more characters. Check to see if its similar to existing customers. */
$("#customerName").change(function () {
if($("#customerName").val().length >= 3) {
$.post("/customers/similarCustomers", $("#customerName").serialize(), function(data) {
$("#similarCustList").html(data);
});
$("#dialog").dialog({
position: 'right',
width: 400
});
$.post("/customers/similarCustomers", $("#customerName").serialize(), function(data) { }
$("#similarCustList").html(data);
});
$("#dialog").dialog({position: 'right', width: 400});
}), }),
$("#CustomerCountryName").autocomplete({ $("#CustomerCountryName").autocomplete({
source: "/countries/completeCountry", source: "/countries/completeCountry",
minLength: 3, minLength: 3,
select: function(event, ui) { select: function(event, ui) {
//alert("You selected " + ui.item.value + " ID:"+ ui.item.id); //alert("You selected " + ui.item.value + " ID:"+ ui.item.id);
$("#CustomerCountryId").val(ui.item.id); $("#CustomerCountryId").val(ui.item.id);
if(ui.item.value == 'Australia') { if(ui.item.value == 'Australia') {
$("#ABN").show(); $("#ABN").show();
} }
else { else {
$("#ABN").hide(); $("#ABN").hide();
} }
} }
}); });