Sorting projects alphabetically in drop down menu

Signed-off-by: Rajani Karuturi <rajanikaruturi@gmail.com>
This commit is contained in:
Daniel Vega 2014-11-05 18:30:58 -02:00 committed by Rajani Karuturi
parent d969364daf
commit e03a7e6fea
1 changed files with 11 additions and 1 deletions

View File

@ -30,11 +30,21 @@
response: {
success: function(args) {
var projects = args.data;
var arrayOfProjs = [];
$(projects).map(function(index, project) {
var proj = {id: _s(project.id), html: _s(project.displaytext ? project.displaytext : project.name)};
arrayOfProjs.push(proj);
});
arrayOfProjs.sort(function(a,b) {
return a.html.localeCompare(b.html);
});
$(arrayOfProjs).map(function(index, project) {
var $option = $('<option>').val(_s(project.id));
$option.html(_s(project.displaytext ? project.displaytext : project.name));
$option.html(_s(project.html));
$option.appendTo($projectSelect);
});
},