ember.js - Emberjs Model updates only partially -
i have table component, feed model. if updated data comes server, push payload store, updates model, , table should re-render.
the problem: despite record updated (see different exchange values) re-rendered, iso value different too. discovered there connection between sortproperties array , re-rendered rows. if change sortproperties to
sortproperties: ['name'],
then rows re-rendered, record's name has been updated.
the expected behavior be, if 3 row re-rendered, since 3 record's exchange property changed.
http://emberjs.jsbin.com/jofulufina/16/edit
some explanation: sortpropertieswithorders
generates string based on asc
, sortproperties
arrays. string used in multisort
, computed.sort property, , multisorting content (the model) of table.
update
i have found solution problem, not flexible @ all: sortpropertieswithorders
should observe each element's exchange property in content. since component, content's property unpredictable, , can't hard code in example. working, not optimal jsbin:
http://emberjs.jsbin.com/bawatonela/1/edit
(hopefully) last update define sortpropertieswithorders
in table component's init. way can build dynamically string of dependent keys it. may find helpful code:
init: function(){ this._super(); var columns = this.get('columns'); var i=0; var cps = []; for(i=0; < columns.length; i++ ){ if (columns[i].property) cps.push(columns[i].property); } var str = 'content.@each.{' + cps.join(',') + '}'; ember.defineproperty(this, 'sortpropertieswithorders', ember.computed(str, 'sortproperties', 'asc', function(){ var ret = ember.a(); var asc = this.get('asc'); this.get('sortproperties').foreach(function(property, i){ var tmp = asc[i] ? property : property + ':desc'; ret.push(tmp); }); return ret; })); },
and working jsbin:
http://emberjs.jsbin.com/bawatonela/3/edit?js,output
idea shamelessly stolen @intuitivepixel https://github.com/emberjs/ember.js/issues/1128#issuecomment-93613364
Comments
Post a Comment