Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : can.List has no prototype.sort() ?

$
0
0
Thanks! Basically all I wanted was Array.prototype.sort() , but without the need to use the semi-cryptic apply() . No escaping it without a plugin for the time being, I guess.

I have another issue, however; my view is not getting updated:

  1. sortColumn: function(scope, element, event)  {
  2.      var comparator = scope.attr("key");
  3.     
  4.     var sorted = Array.prototype.sort.apply( this.attr("files"), [function(a,b)  {
  5.         a = a.attr("sloc").attr(comparator);
  6.         b = b.attr("sloc").attr(comparator);
  7.          
  8.         if ( this.attr("ascending") )  {
  9.             return a===b ? 0 : a<b ? -1 : 1;
  10.         }  else  {
  11.             return a===b ? 0 : a>b ? -1 : 1;
  12.         }
  13.     }.bind(this)]);
  14.     
  15.     this.attr("files", sorted);
  16. },

Viewing all articles
Browse latest Browse all 3491

Trending Articles