observeNodes for distributed content

2019-09-08 14:09发布

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?

0条回答
登录 后发表回答