core-ajax - call a function straight with on-core-response

127 views
Skip to first unread message

mrteu...@gmail.com

unread,
Dec 5, 2014, 4:41:05 PM12/5/14
to polym...@googlegroups.com
I would like to call a function straight out of core-ajax - is that possible??

I have two search fields each with a 'currentLocation' button. When the button is clicked, it requests the current location (lat, lng) from the browser (getGeoLocation) and sends lat, lng and output-SearchField to the core-ajax.
It then should display the formatted address in the search field close to where the button was clicked.
(I can catch the results from the php file with addEvent Listener fine but in the process, I loose the search field where it should be displayed.)

Here my code, sorry still struggling my way through but I really like the potential of Polymer.

 <core-ajax
   
id="getAddressFromLatLng"
   
auto
   
url="php-include/phpAddressFromLatLong.php"
   
method="POST"
   
params='{"lat":"51.339", "lng":"12.373", "SearchField":""}'
   
handleAs="json"
   
on-core-response= "function(){
       console.log(response);
       document.getElementById("
SearchField").value = response.detail.response;
   }"
>
 
</core-ajax>





Thanks for your help and comments.

Rob Dodson

unread,
Dec 5, 2014, 4:58:15 PM12/5/14
to mrteu...@gmail.com, polymer-dev
I don't think it's possible to call a function from an on-* attribute. The easier thing would be to have that method on your polymer element, or listen for the event it triggers and run the method in response to that.

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/a48df216-e2e1-4a95-afdb-4104033c5bb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages