Javascript 使用核心页面时,是否存在页面加载事件?

Javascript 使用核心页面时,是否存在页面加载事件?,javascript,event-handling,polymer,Javascript,Event Handling,Polymer,在核心动画页面集合中,我需要我的所选页面对它成为所选页面这一事实做出反应。我不知道该在哪里捕捉什么事件。尝试了一个简单的加载,但没有被调用 如果默认情况下没有这样的事件,那么on-core select能否以某种方式触发my元素中的事件,让它知道应该加载它的数据 <core-animated-pages id="appPages" selected="{{selectedPage}}" valueattr="data-name" transitions="slide

在核心动画页面集合中,我需要我的所选页面对它成为所选页面这一事实做出反应。我不知道该在哪里捕捉什么事件。尝试了一个简单的加载,但没有被调用

如果默认情况下没有这样的事件,那么on-core select能否以某种方式触发my元素中的事件,让它知道应该加载它的数据

            <core-animated-pages id="appPages" selected="{{selectedPage}}" valueattr="data-name" transitions="slide-from-right" on-core-select="{{pageSelected}}">
                <my-page data-name="Round 1" color="red">
                    <div>Page 1</div>
                </my-page>
                <my-page data-name="Round 2" color="yellow">
                    <div>Page 2</div>
                </my-page>
                <my-page data-name="Round 3" color="grey">
                    <div>Page 3</div>
                </my-page>
            </core-animated-pages>



<polymer-element name="my-page" attributes="color">
<template>
    <section data-name="Round 1" layout vertical center center-justified style="background:{{color}};">
        <content></content>
    </section>
</template>
<script>
    Polymer('my-page', {
        load: function (e) {
            console.info(e)
        }
    });
</script>

基于核心动画页面文档,元素采用您的名称并查找包含相同单词的元素。例如:

<core-animated-pages transitions="hero-transition">
   <section id="page1">
     <div id="hero1" hero-id="hero" hero></div>
   </section>
   <section id="page2">
      <div id="hero2" hero-id="hero" hero></div>
  </section>
</core-animated-pages>
这将帮助您避免编写逻辑来显示/隐藏元素。
文档还显示转换发生前后触发的事件。

似乎有两个事件在不同时间触发:

核心动画页面转换准备和 核心动画页面过渡结束。 发件人:


我所做的与你所说的接近的事情是使用flatiron director,将我的核心动画页面中的每一页都设置为一条路线,并倾听路线的变化,然后执行我的功能。谢谢,我想我现在也在做类似的事情,请参阅下一个答案上的评论。很高兴你能成功。据我所知,这两种方法在功能上的唯一区别是使用flatiron director,您可以获得路由页面。。例如:www.url.compage1。我本应该发布我的代码,但我不能100%确定这就是你想要的。这很有趣,但对我来说似乎没有帮助。这两个事件处理程序似乎没有关于它所处理的页面的任何信息。死胡同我回去检查了所选的on-core,事实上,detail.item可以用来获取页面中的内容,特别是核心ajax元素,然后我可以触发go-on来获取新数据。谢谢你让我重新思考:-
<!--
  Fired before a page transition occurs. Both pages involved in the transition are visible when
  this event fires. This is useful if there is something the client needs to do when a page becomes visible.

  @event core-animated-pages-transition-prepare
-->

<!--
  Fired when a page transition completes.

  @event core-animated-pages-transition-end
-->