2016-12-13 5 views
0

に変更されたとき、私は、ポリマー中にこのDOMリピートテンプレートを持ってフォーステンプレート全体を再レンダリングデータは、DOMリピート

<template is="dom-if" if="true"> 
    <typeahead items="{{item.children}}"></typeahead> 
</template> 

<template is="dom-repeat" id="level" items="{{item.children}}"> 
    <li on-click="itemClickHandler" id$="[[getItemId(item)]]" class$="{{isItemSelected(item, selectedItem)}}" > 
    <template is="dom-if" if="[[!toShowColumnTypeahead()]]"><span>{{getItemLabel(item)}}</span></template> 
    <template is="dom-if" if="[[toShowColumnTypeahead()]]"> 
     <template is="dom-if" if="[[!item.searchTerm]]" restamp="true"> 
     <span class="f">{{getItemLabel(item)}}</span> 
     </template> 
     <template is="dom-if" if="{{item.searchTerm}}" restamp="true"> 
     <span class="">{{item.currentSearchLabel.prefix}}<span class="bold">{{item.currentSearchLabel.highlight}}</span>{{item.currentSearchLabel.suffix}}</span> 
     </template> 
    </template> 
    <button class$="[[getItemOpenerClass(item)]]" on-click="openClickHandler" key$="[[getItemId(item)]]">Open</button> 
    <template is="dom-if" if="{{_hasChildren(item, showChevron)}}"> 
     <span class="chevron"><i class="fa fa-angle-right"></i></span> 
    </template> 
    </li> 
</template> 

item.childrenのためのデータは、先行入力のポリマー成分から変化しており、その、それを通知します。しかし、items.childrenが変更され、以前の結果の一部であった場合、それはnot redrawn on domI want it to be redrawn on DOM every timeです。以前の変更の一部であるかどうかにかかわらずリストに変更があります。現在、PolymerはDOM上の変更された要素のみを再描画します。私はthis.setからmanually calling the renderの方法で網から非常に多くのものを試しました。query selecting the templateによって。

答えて

0

は、私はあなたに100%従っ完全にはよく分からないが、あなたは破壊し、毎回item.childrenが変更された要素を再作成するためにそれを強制的に、DOMリピートに restampを使用して試みることができます。 は、あなたが確認するかもしれないので、

レンダリングが同期通常、非同期で実行される変更をレンダリングする強制しますが、それは唯一のポリマーAPIを介して行われた変更をピックアップする場合は、DOM-restampが実際にのみに動作しますが、これを無視しますitem.childrenに加えられた変更は、固有の配列関数だけではなく、Polymer APIを介して行われます。つまり、通常のtheArray.pushではなくthis.push( 'theArray'、newItem)の行に沿って何かを行う設定です。 (新商品))。

編集:再同期の変更をレンダリングする「だけ」の力をレンダリング呼び出し

  • を、これは
  • あなたの問題をレンダリング通常の非同期はおそらく来るより多くのものをレンダリング強制べきではありません。さらに明確にします配列が更新される方法から。配列を変異させるには、this.splicethis.pushthis.popthis.unshiftまたはthis.shiftを使用してください。 Link to the doc
関連する問題