javascript - Extending Ember.ArrayProxy -
how extend ember.arrayproxy? have tried following:
ember.arrayproxy.reopenclass({ flatten: function(){ var r = []; this.foreach(function(el) { r.push.apply(r, ember.isarray(el) ? el.flatten() : [el]); }); return r; } }); but ended writing following solution:
// source: https://gist.github.com/mehulkar/3232255 array.prototype.flatten = ember.arrayproxy.prototype.flatten =function() { var r = []; this.foreach(function(el) { r.push.apply(r, ember.isarray(el) ? el.flatten() : [el]); }); return r; }; is there i'm missing in former example? i'm trying stick ember's methodology, prefer not use later.
if you're using flatten on instances of arrayproxy you'd want use reopen, , not reopenclass. reopenclass adds method class itself, aka call em.arrayproxy.flatten()
Comments
Post a Comment