aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/stop_areas
diff options
context:
space:
mode:
authorLuc Donnet2014-08-06 16:53:13 +0200
committerLuc Donnet2014-08-06 16:53:13 +0200
commit8ca6a3feee28f3e04cd043a015cf6f30057cf2ac (patch)
tree330c7ba578c96e9a5093782fa2b2d4d7dd01be43 /app/views/stop_areas
parent9d1fe609029098d1c2ae40980b133923cd890cf2 (diff)
downloadchouette-core-8ca6a3feee28f3e04cd043a015cf6f30057cf2ac.tar.bz2
Fix use of adresses in new and edit form for stop_areas
Diffstat (limited to 'app/views/stop_areas')
-rw-r--r--app/views/stop_areas/_form.html.erb31
1 files changed, 13 insertions, 18 deletions
diff --git a/app/views/stop_areas/_form.html.erb b/app/views/stop_areas/_form.html.erb
index 1282606f5..eefae9c16 100644
--- a/app/views/stop_areas/_form.html.erb
+++ b/app/views/stop_areas/_form.html.erb
@@ -60,8 +60,6 @@
<script>
var addressesEngine = new Bloodhound({
- // datumTokenizer: Bloodhound.tokenizers.obj.whitespace('the_key'),
- // queryTokenizer: Bloodhound.tokenizers.whitespace,
datumTokenizer: function(d) {
return Bloodhound.tokenizers.whitespace(d.id+" : "+d.road);
},
@@ -70,7 +68,7 @@
},
limit: 10,
remote: {
- url: 'addresses?q=%QUERY',
+ url: '<%= addresses_referential_stop_areas_path(@referential, :format => 'json') %>?q=%QUERY',
filter: function(list) {
return $.map(list, function(d) { return { postcode: d.postcode, road: d.road, lon: d.lon, lat: d.lat, city: d.city, postcode: d.postcode, the_key: d.house_number+" "+d.road+", "+d.postcode+" "+d.city+", "+d.country }; });
},
@@ -79,24 +77,21 @@
// kicks off the loading/processing of `local` and `prefetch`
var promise = addressesEngine.initialize();
-
- // promise.done(function() { console.log('success!'); });
- // promise.fail(function() { console.log('err!'); });
// passing in `null` for the `options` arguments will result in the default
// options being used
- $('#prefetch .typeahead').typeahead({
- hint: true,
- highlight: true,
- minLength: 1
- },
- {
- name: 'addresses',
- displayKey: 'the_key',
- // `ttAdapter` wraps the suggestion engine in an adapter that
- // is compatible with the typeahead jQuery plugin
- source: addressesEngine.ttAdapter(),
- });
+ $('#prefetch .typeahead').typeahead(
+ {
+ hint: true,
+ highlight: true,
+ minLength: 1
+ },
+ {
+ name: 'addresses',
+ displayKey: 'the_key',
+ source: addressesEngine.ttAdapter(),
+ }
+ );
$('.typeahead').on('typeahead:selected', function($e, datum) {
$('input[name="stop_area[longitude]"]').val(datum.lon);