Sha256: 98cbf3d9a924eabcdcdd5f4ba131e4b37ac7b388fe81abb9652c9a7e86f548eb
Contents?: true
Size: 1.7 KB
Versions: 10
Compression:
Stored size: 1.7 KB
Contents
.row.address-fields = form.hidden_field :egov_identifier .col-6 = form.text_field :street .col-3 = form.text_field :house_number .col-3 = form.text_field :orientation_number .col-12 = form.text_field :city = form.text_field :postcode = form.select :district, EgovUtils::Address.districts.collect{|r| [r[:name],r[:name]]} = form.select :region, EgovUtils::Address.regions.collect{|r| [r[:name],r[:name]]} -# form.text_field :country %div.validation-button = link_to t('label_find'), 'javascript:void(0)', class: 'btn btn-secondary address-validator-btn' :javascript $(function(){ $('.address-validator-btn').not('.validator-initialized').on('click', function(evt) { var values = {}, $fields = $(this).closest('.address-fields'); $fields.find(':input').each(function(i){ var name, name_m = $(this).attr('name').match(/\[([^\[]*)\]$/); name = name_m[1]; values[name] = $(this).val(); }); $.ajax('#{egov_utils.validate_ruian_path}', { method: 'GET', dataType: 'json', data: { address: values } }).done(function(json){ var field; for( var key in json ) { field = $fields.find("[name$='["+key+"]']"); if( field.length !== 1 || !json[key] ) continue; field.val(json[key]); } }).fail(function(xhr, status, errorMsg){ $('#modal').modal('hide'); eGovUtilities.showModal(xhr.responseJSON.error, {modalId: 'modalAlert', backdrop: 'static'}).on('hidden.bs.modal', function(){ $('#modal').modal('show'); }); }); }).addClass('.validator-initialized'); });
Version data entries
10 entries across 10 versions & 1 rubygems