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()

http://emberjs.jsbin.com/oqufobeg/1/edit


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -