I have an Ember Array Controller that is binded to Ember select view that gets sorted by the user if they choose to. Once everything runs through my sort and I reset the array with the now sorted array the view doesn't change but if I loop through the array that I just set, it shows that it is sorted. So the view isn't updating with the array controller, I believe. I was looking at other posts with similar problems but none of the solutions from them worked for me.
dmp: Ember.ArrayController.create(),
tempArray: new Array(),
sort: function() {
debugger;
var self = this;
var textA, textB, i, t, pos, temp;
this.set('tempArray', self.dmp.get('content'));
var nxt;
for(t = 0; t < (self.get('tempArray').length) - 1; t++) {
nxt = this.get('tempArray')[t];
for(i = t; i < self.get('tempArray').length; i++) {
if(self.get('tempArray')[i].name.toUpperCase() <= nxt.name.toUpperCase()) {
nxt = self.get('tempArray')[i];
pos = i;
}
}
temp = self.get('tempArray')[t];
self.get('tempArray')[t] = nxt;
self.get('tempArray')[pos] = temp;
}
//App.defRouteSearch.dmpName.set('content', self.get('tempArray'));
//App.defRouteSearch.dmp.set('content', self.get('tempArray'));
self.setArray();
},
setArray: function() {
debugger;
var a = 0, b = 1;
var self = this;
while(a < this.get('tempArray').length) {
self.get('dmp').toArray[b] = self.get('tempArray')[a];
a++;
b++;
}
}
I switch everything over to a normal js array because it's quicker to manipulate data than compared to the Array Controller, I do this throughout the rest of my code when filling the 6 other arrays I have so that's not causing any problems. The commented code was what I was doing before to set the array. Thanks for any help.