/* * filename: findcustomer.js * * used in: customers/find.ctp * */ $(function() { $("#dialog").hide(); /*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) { findCustomer(); } }); $("#findButton").button().click(function() { findCustomer(); return false; }); } ); function findCustomer() { $.post("/customers/similarCustomers", $("#customerName").serialize(), function(data) { $("#similarCustList").html(data); }); $("#dialog").dialog({ position: 'top', width: 800 }); }