2015-10-06 09:38:52 +02:00
|
|
|
h1 = title t('.title_html')
|
2015-10-05 12:40:08 +02:00
|
|
|
= simple_form_for @supporter do |f|
|
|
|
|
|
= f.input :first_name
|
|
|
|
|
= f.input :last_name
|
|
|
|
|
= f.input :street
|
2015-10-05 14:12:05 +02:00
|
|
|
= f.input :city
|
2015-10-06 17:33:29 +02:00
|
|
|
= f.input :zip
|
2015-10-05 12:40:08 +02:00
|
|
|
= f.input :email
|
|
|
|
|
= f.input :support, as: :radio_buttons, collection: t('support_type'), label_method: :last, value_method: :first
|
|
|
|
|
= f.input :age_category, as: :radio_buttons, collection: t('age_category'), label_method: :last, value_method: :first
|
|
|
|
|
= f.submit value: t('.submit'), class: 'btn btn-success'
|
2015-10-06 11:46:27 +02:00
|
|
|
|
|
|
|
|
javascript:
|
|
|
|
|
var cities = new Bloodhound({
|
|
|
|
|
datumTokenizer: Bloodhound.tokenizers.whitespace,
|
|
|
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
|
|
|
remote: {
|
|
|
|
|
url: '/cities_autocomplete.json?query=%QUERY',
|
|
|
|
|
wildcard: '%QUERY',
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-10-06 16:23:52 +02:00
|
|
|
var suggestion_template = function (data) {
|
|
|
|
|
return '<p>' + data.plz + ' - ' + data.city + '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-06 11:46:27 +02:00
|
|
|
$('#supporter_city').typeahead({
|
|
|
|
|
minLength: 2,
|
|
|
|
|
},{
|
2015-10-06 16:18:04 +02:00
|
|
|
limit: 20,
|
|
|
|
|
display: 'city',
|
|
|
|
|
templates: {
|
|
|
|
|
suggestion: function (data) {
|
2015-10-06 16:23:52 +02:00
|
|
|
return suggestion_template(data);
|
2015-10-06 16:18:04 +02:00
|
|
|
}
|
|
|
|
|
},
|
2015-10-06 11:46:27 +02:00
|
|
|
source: cities
|
|
|
|
|
}).on('typeahead:selected', function(event, datum) {
|
|
|
|
|
$("#supporter_zip").val(datum.plz);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#supporter_zip').typeahead({
|
|
|
|
|
minLength: 2,
|
|
|
|
|
},{
|
2015-10-06 16:18:04 +02:00
|
|
|
limit: 20,
|
2015-10-06 11:46:27 +02:00
|
|
|
display: 'plz',
|
2015-10-06 16:18:04 +02:00
|
|
|
templates: {
|
|
|
|
|
suggestion: function (data) {
|
2015-10-06 16:23:52 +02:00
|
|
|
return suggestion_template(data);
|
2015-10-06 16:18:04 +02:00
|
|
|
}
|
|
|
|
|
},
|
2015-10-06 11:46:27 +02:00
|
|
|
source: cities
|
|
|
|
|
}).on('typeahead:selected', function(event, datum) {
|
|
|
|
|
$("#supporter_city").val(datum.city);
|
|
|
|
|
});
|