aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/map-OpenLayers.js
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-10-02 12:29:31 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-10-02 12:29:31 +0100
commit85293da04381215fbf8384ec2e8d99d9862d6129 (patch)
tree920cdd86390062fa593f16ab12ad62a3d56e2ec6 /web/js/map-OpenLayers.js
parent0d5cd3beb1aac885614fa3ca19a7e6c054bad65c (diff)
parentfb86b4dd50ad68b8f14351037d077d6cf9bc82b5 (diff)
Merge branch 'issues/commercial/1188-push-state'
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r--web/js/map-OpenLayers.js26
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;
}