Polymer: reverting/ordering items in repeat without touching array order -


this seems trivial thing i'm unable find it:
what if want reverse order of items in repeat, without touching order of array, in:

<template repeat="{{layer in layers}}">  <div>{{layer.name}}</div> </template> 

where layers array of objects.
i've tried applying filter , working copy of array, in:

<template repeat="{{layer in layers | reverse}}">  <div>{{layer.name}}</div> </template> ... reverse: function(arr){    return _(arr).reverse(); } 

but results in observers failing since they're looking @ copy instead of original objects. don't want apply sort original array since other parts of code depend on order.
knows of option order of display in dom affected?

i think need this

<template repeat="{{layer in temp_array}}">  <div>{{layer.name}}</div> </template>  <script>      polymer('el-name',{          ready: function(){              this.temp_array =[];              this.temp_array = layers.reverse();          }      } ); </script> 

if layers empty when ready called, use change listener

<script>          polymer('el-name',{              ready: function(){                  this.temp_array =[];               },              layerschanged: function(oldvalue, newvalue){                  if(newvalue.length != 0)                     this.temp_array = newvalue.reverse();              }           }     );     </script> 

hope you


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -