diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-10-01 15:00:59 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-10-02 11:10:36 +0100 |
commit | fb86b4dd50ad68b8f14351037d077d6cf9bc82b5 (patch) | |
tree | 972b9567003425c4771bd4a9b0ec1a9e7f0fde5d /web/js | |
parent | c2dfa30bad7f17f702985a535f8a0d72b0f47183 (diff) |
Fix history API bug.
replace_query_parameter() was stringifying select multiples, meaning
they were incorrectly recorded by the pushState and thus breaking on
navigation.
Diffstat (limited to 'web/js')
-rw-r--r-- | web/js/map-OpenLayers.js | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index efa457928..30223d21d 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -412,17 +412,25 @@ $.extend(fixmystreet.utils, { } function replace_query_parameter(qs, id, key) { - var value = $('#' + id).val(); - if ( $('#' + id).prop('type') == 'checkbox' ) { - value = $('#' + id).prop('checked') ? '1' : ''; - } else if (value) { - value = (typeof value === 'string') ? value : fixmystreet.utils.array_to_csv_line(value); + var value, + $el = $('#' + id); + if (!$el[0]) { + return; } - - if (value) { - qs[key] = value; + if ( $el[0].type === 'checkbox' ) { + value = $el[0].checked ? '1' : ''; + if (value) { + qs[key] = value; + } else { + delete qs[key]; + } } else { - delete qs[key]; + value = $el.val(); + if (value) { + qs[key] = (typeof value === 'string') ? value : fixmystreet.utils.array_to_csv_line(value); + } else { + delete qs[key]; + } } return value; } |