2017-03-02 1 views

答えて

0

MutationObserverを使用すると、必要な処理を行うことができます。

DivElementにObserverを設定し、childList個の突然変異を観察します。 MutationRecordには、addedNodesリストを得ることができます。

はMutationObserverにはネイティブGWTのサポートはありませんので、あなたは、JSNIを使用する必要があります。

private native void addListener(Element elem) /*-{ 
    // create an observer instance 
    var observer = new MutationObserver(function(mutations) { 
     mutations.forEach(function(mutation) { 
      if(mutation.type == 'childList') { 
       // mutation.addedNodes contains nodeList of added nodes 
       $wnd.alert('Nodes added'); 
      } 
     }); 
    }); 

    // configuration of the observer: 
    var config = { 
     childList : true 
    }; 

    // pass in the target node, as well as the observer options 
    observer.observe(elem, config); 
}-*/; 

ちょうどあなたのDivElementにaddListener(div);を呼び出します。

関連する問題