I'm new in ember and recently I encounter some difficulties. I'm trying to use google map autocomplete. In my JavaScript example everything works great.
<html>
<head>
<title>Autocomplete</title>
<script src="http://ift.tt/1ayd29L" type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
var options = {
types: ['(cities)']
};
var input = document.getElementById('searchField');
var autocomplete = new google.maps.places.Autocomplete(input, options);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div>
<input id="searchField" type="text" size="50" placeholder="Location..." autocomplete="off">
</div>
</body>
</html>
But in my ember application when i select location with my mouse input box value is not changing (it works only for keyboard). For example. I'm writing New Yo, and then select New York from drop down list but my value is still New Yo
This is my code:
app/components/gmap-search.js
import Ember from 'ember';
export default Ember.Component.extend({
searchTextField: function() {
var options = {
types: ['(cities)']
};
var input = this.$('.search-field')[0];
new window.google.maps.places.Autocomplete(input, options);
}.on('didInsertElement')
});
app/templates/components/gmap-search.hbs
{{input class="search-field form-control" type="text" value=offer.location placeholder="" required="required"}}
app/templates/application.hbs
{{gmap-search offer=offer }}
I will be grateful for any help
Aucun commentaire:
Enregistrer un commentaire