Only removes locality text field if we display a locality list.
authorStéphane Jacob <sj@m4x.org>
Sat, 11 Jun 2011 12:20:36 +0000 (14:20 +0200)
committerStéphane Jacob <sj@m4x.org>
Sat, 11 Jun 2011 12:20:36 +0000 (14:20 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
htdocs/javascript/search.js

index 6ad9c4a..e544410 100644 (file)
@@ -224,15 +224,14 @@ function setAddress(i, j, values)
     var next_type = address_types[j];
     var next_list = next_type + '_list';
 
-    if (j == 3) {
-        $('tr#locality_text').hide()
-            $("select[name='locality_text']").attr('value', '');
-    }
-
     $('#' + next_list).load(baseurl + 'list/' + next_type, { previous:prev_type, value:values[i] }, function() {
         if ($("select[name='" + next_type + "']").children("option").size() > 1) {
             $("tr#" + next_type).show();
             $("select[name='" + next_type + "']").attr('value', values[j]);
+            if (next_type == 'locality') {
+                $('tr#locality_text').hide();
+                $("select[name='locality_text']").attr('value', '');
+            }
             if (j < address_types_count) {
                 setAddress(j, j + 1, values);
             }