diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-04-24 20:10:40 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-04-24 20:10:40 +0100 |
commit | a9f5ff1d3d0c045d1ef4aae01295a0d8daab5f9f (patch) | |
tree | 4d4a778d6f2af02eca4633b7ee136911e852a5e0 /web | |
parent | f70ef9f6a612d3387db24519e163e6b326a9fb64 (diff) |
Maintain category group on pin move.
If the same category is in multiple groups, upon moving the pin and
fetching new categories from the server it would then pick the last
instance of that category in the list. Instead of using val(), pick
the correct entry in the previously selected optgroup.
Diffstat (limited to 'web')
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 15ba18df4..f0b4cbb84 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -1362,7 +1362,10 @@ fixmystreet.fetch_reporting_data = function() { } $('#form_category_row').html(data.category); - if ($("#form_category option[value=\"" + old_category + "\"]").length) { + var cat_in_group = $("#form_category optgroup[label=\"" + old_category_group + "\"] option[value=\"" + old_category + "\"]"); + if (cat_in_group.length) { + cat_in_group.prop({selected:true}); + } else if ($("#form_category option[value=\"" + old_category + "\"]").length) { $("#form_category").val(old_category); } else if (filter_category !== undefined && $("#form_category option[value='" + filter_category + "']").length) { // If the category filter appears on the map and the user has selected |