yefan15
September 27, 2018, 6:38pm
1
I am running into the issue where when using ember place autocomplete search bar as a component it is not recognizing the placeChangedCallback function defined in the actions in my component. I am not sure what is going on.
Template:
<p id=“message”>Message: {{message}}</p>
<p>Full adddress from JSON sent to the callback: {{{fullAddress}}}</p>
<p>Clean string: {{cleanFullAddress}}</p>
<p> Model address: {{address}}</p>
<div id=“search-bar” data-google-auto=“{{googleAuto}}”>
<label class=“visually-hidden” for=“input-search”>Add a new address</label>
{{place-autocomplete-field
id=“input-search”
value= address
handlerController= this
placeholder=“Add a new address”
inputClass= ‘place-autocomplete–input’
placeChangedCallback= “addressChanged”
focusOutCallback=“done”
restrictions=googleMapsRestrictions
withGeoLocate= true
}}
<pre style=“font-size: 6px;”>
{{placeJSON}}
</pre>
Component:
googleMapsRestrictions: {
country: ‘us’,
},
fullAddress: null,
googleAuto: null,
action: {
done(){
console.log(“Reached”);
},
addressChanged(place) {
console.log(“***********”+place);
}
}
Hey @yefan15 ,
Could you take a look at the issue? I leave a short answer there:
opened 08:31PM - 27 Sep 18 UTC
closed 10:19PM - 06 Feb 19 UTC
When I declare placeChangedCallback=(action "placeChanged") I get TypeError: Can… not read property 'apply' of undefined. and when I use placeChangedCallback='placeChanged' it doesn't get called at all. Is there something I need to do special if I am creating a search bar component that is going to be used else where? The logic for the action is defined in my component js file. I am also noticing the same behavior with the focusOutCallback
Here is a snippet:
```hbs
Template (search-bar-address):
<p id=“message”>Message: {{message}}</p>
<p>Full adddress from JSON sent to the callback: {{{fullAddress}}}</p>
<p>Clean string: {{cleanFullAddress}}</p>
<p> Model address: {{address}}</p>
<div id=“search-bar” data-google-auto="{{googleAuto}}">
<label class=“visually-hidden” for=“input-search”>Add a new address</label>
{{place-autocomplete-field
id=“input-search”
value= address
handlerController= this
placeholder=“Add a new address”
inputClass= ‘place-autocomplete–input’
placeChangedCallback= “addressChanged”
focusOutCallback=“done”
restrictions=googleMapsRestrictions
withGeoLocate= true
}}
<pre style=“font-size: 6px;”>
{{placeJSON}}
</pre>
googleMapsRestrictions: { country: ‘us’, },
fullAddress: null,
googleAuto: null,
action: { done()
{ console.log(“Reached”); },
addressChanged(place) { console.log("***********"+place);
}
}
Where it is implemented
{{search-bar-address
id="search-bar-component"
}}
```
I will try to focus on having a better documentation about how to use the addon before the year ends.
Best regards,
Daniel
1 Like