Reloading page on every click using Polymer and app-route

微笑、不失礼 提交于 2019-12-02 09:59:27

you should definitely add on-tap to render new images. Your image won't change, because iron-pages are observing some value (specified in selected property) so, when you click on main-view and route property already had value "main-view", observer will not trigger.

Adding on-tap on element that is handling changes will make it always trigger. Some easy example:

<iron-pages selected="{{route}}" attr-for-selected="name">
  <example-element name="main-view" on-tap="handleClick" id="main"></example-element>
  <another-element name="second-view"></another-element> 
</iron-pages>

and inside handleClick function something like:

handleClick: function() {
  this.$.main.renderImage();
}

Of course inside main-view element you can declare renderImage function which will handle rest of the logic

And don't forget to make some debounce since you don't want to propably render 20 new images in 1 second. You can use Polymer native debounce function You can read more about it here: https://www.polymer-project.org/1.0/docs/devguide/instance-methods

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!