Skip to content

Commit

Permalink
Clear latlong when changing place textbox to enforce validation fail …
Browse files Browse the repository at this point in the history
…when autocomplete suggestion not selected
  • Loading branch information
dshoulders committed Sep 18, 2013
1 parent 3a4eac8 commit dcb17aa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Web/Squirrel/Scripts/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ ko.bindingHandlers.addressAutocomplete = {
var value = valueAccessor(),

defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(51.478389,-0.143616),
new google.maps.LatLng(51.534804,-0.052979)), // central London
new google.maps.LatLng(51.478389, -0.143616),
new google.maps.LatLng(51.534804, -0.052979)), // central London

options = { bounds: defaultBounds },

Expand All @@ -223,8 +223,15 @@ ko.bindingHandlers.addressAutocomplete = {

value(place.formatted_address);
bindingContext.$data.latLong(place.geometry.location.lat() + ',' + place.geometry.location.lng());
console.log(bindingContext.$data.latLong());
});

element.addEventListener('input', function (event) {
bindingContext.$data.latLong(null);
value(event.target.value);
console.log(bindingContext.$data.latLong());
}, false);

$.subscribe('currentLocation', function (_e, position) {
autocomplete.setBounds(convertToBounds(new google.maps.LatLng(position.coords.latitude, position.coords.longitude), 10000));
});
Expand Down

0 comments on commit dcb17aa

Please sign in to comment.