Polymer: Access Polymer Element Objects
Solution 1:
Define it outside of the function and then you should be able to use it externally. This format will work for the .8 version. 1.0 version will need to use the new format.
created: function() {
this.response = [];
},
labels: undefined,
postsLoaded: function() {
Solution 2:
You should read about databinding here
Don't do this:
<core-ajax id="ajax"
auto
url="{{url}}"
method="get"
contentType = 'application/json'
on-core-response="{{postsLoaded}}"
body="{{body}}"
handleAs="xml">
</core-ajax>
Do this instead:
<core-ajax id="ajax" auto url="{{url}}" method="get" contentType ='application/json' on-core-response="{{postsLoaded}}" body="{{body}}" handleAs="xml"></core-ajax>
Putting the bindings on different lines isnt supported yet
Solution 3:
There is other ways you can try to access the values, try
var yourElement = document.getElementById('gservice');
if This doesn't work, try with 'querySelector' as shown below:
<gis-service id="gservice" class="gservice"
response="{{labels}}" url="someUrl">
</gis-service>
<script>
var gis_service = document.querySelector('gservice');
console.log(gis_service);
</script>
See the additional class attribute.
Also i recommend you to upgrade to Polymer 1.0, because it allows more robust ways to do things...
Post a Comment for "Polymer: Access Polymer Element Objects"