can you tell me how can i reload an iron-ajax when i opened a page. For example: I have page /news. When i clicked for this page i am opened element:
<dom-module id="my-news">
<template id="app">
<iron-ajax id="ajax_list"
auto
url="http://--------------/books"
last-response="{{data}}"
handleAs="json"
on-response="handleResponse">
</iron-ajax>
<iron-list id="news_list" items="[[data]]">
<template >
<paper-item on-tap="open_news">[[item.name]] </paper-item>
</template>
</iron-list>
</template>
<script>
Polymer({
is: 'my-news',
},
....
</script>
If at this point to add news, the list is not updated. It is updated only when I press F5 and iron-ajax will work again. I am create a function like this:
ready: function(){
var _this_ = this;
function(){this.ajax_list.generateRequest();}, 5000)
}
But this is not exit
In order to work, your function need to get the iron-ajax
instance, and for that you need to use this.$
instead of this
. You also need to bind the function with bind(this)
in order to pass the element instance to the callback.
Something like that:
ready: function(){ var _this_ = this; function(){ this.$.ajax_list.generateRequest() }.bind(this), 5000) },
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.