aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-10-26 09:14:22 +0100
committerDave Arter <davea@mysociety.org>2018-11-02 15:54:09 +0000
commite5eab60d971bbf97583a555d72374085ec45b5d4 (patch)
tree0384b5c6567b1afd7a9e61360a80ba471960763a /web
parentb27cd116c94f2f1edb97d32a9c7f0f9c7cf10aaf (diff)
Sort category groups correctly
Previously if there was a mix of groups and top-level categories they weren’t sorted together.
Diffstat (limited to 'web')
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index af69a536e..97d53dd01 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -504,6 +504,17 @@ $.extend(fixmystreet.set_up, {
add_option(this);
}
});
+ // Sort elements in place, but leave the first 'pick a category' option alone
+ $group_select.find("option").slice(1).sort(function(a, b) {
+ // 'Other' should always be at the end.
+ if (a.label === 'Other') {
+ return 1;
+ }
+ if (b.label === 'Other') {
+ return -1;
+ }
+ return a.label > b.label ? 1 : -1;
+ }).appendTo($group_select);
$group_select.change();
},