From: Stéphane Jacob Date: Thu, 9 Jun 2011 21:23:27 +0000 (+0200) Subject: Do not change text field to list field once a country is selected using the autocompl... X-Git-Tag: xorg/1.1.2~30 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=4dea11cc65e33b422a1fb59c03ee6fb8265577af;p=platal.git Do not change text field to list field once a country is selected using the autocomplete; factorizes code. Signed-off-by: Stéphane Jacob --- diff --git a/htdocs/javascript/search.js b/htdocs/javascript/search.js index 9492128..4347c33 100644 --- a/htdocs/javascript/search.js +++ b/htdocs/javascript/search.js @@ -171,28 +171,24 @@ function select_autocomplete(name) } } - // When changing country or locality, open next address component. - if (field_name == 'country' || field_name == 'locality') { + // When changing country, locality or school, open next address component. + if (field_name == 'country' || field_name == 'locality' || field_name == 'school') { return function(i) { if (i.extra[0] < 0) { cancel_autocomplete(name, field_name); i.extra[1] = ''; } - $("[name='" + field_name + "']").parent().load(baseurl + 'list/' + field_name, function() { - $("select[name='" + field_name + "']").attr('value', i.extra[1]); - }); - changeAddressComponents(field_name, i.extra[1]); - } - } - if (field_name == 'school') - return function(i) { - if (i.extra[0] < 0) { - cancel_autocomplete('school_text', 'school'); - i.extra[1] = ''; + if (field_name == 'school') { + changeSchool(i.extra[1], ''); + } else { + changeAddressComponents(field_name, i.extra[1]); } - changeSchool(i.extra[1], ''); + + $(".autocomplete_target[name='" + field_name + "']").attr('value', i.extra[1]); + $(".autocomplete[name='" + name + "']").addClass('hidden_valid'); } + } // change field in list and display text field as valid return function(i) {