observeNodes for distributed content

痴心易碎 提交于 2019-12-12 04:09:45

问题


Let's say I have an element that has an insertion point inside.

    <dom-module id="some-el">
      <template>
<content id="con"></content>
      </template>
      <script>
        (function () {
          Polymer({
            is: 'some-el',

            ready:function(){
              var placeholder = Polymer.dom(this).querySelector('div[id*="placeholder"]');

             this._observer=Polymer.dom(placeholder ).observeNodes(function(info){
             console.log(info.addedNodes)
             });

           }
          });
        })();
      </script>
</dom-module>

and in DOM it looks like this where #placeholder... is a spinning wheel container, which replaces the span inside with content received via ajax.

<some-el><div id="placeholder_GUIDstuff"><span>spinner</span></div></some-el>

So basically I need to know when the #placeholder_... is changed, but I can't subscribe to it (when i do, nothing is returned when it changes), only to the content element, but it doesn't trigger when its immediate children get changed.

What can be the solution?

来源:https://stackoverflow.com/questions/34286381/observenodes-for-distributed-content

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