aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/js/fixmystreet.js7
-rw-r--r--web/js/map-OpenLayers.js5
-rw-r--r--web/js/southampton.js16
3 files changed, 14 insertions, 14 deletions
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js
index b1a8f1889..834aa4ed3 100644
--- a/web/js/fixmystreet.js
+++ b/web/js/fixmystreet.js
@@ -8,7 +8,7 @@ function form_category_onchange() {
var args = {
category: cat.val()
};
-
+
if ( typeof fixmystreet !== 'undefined' ) {
args.latitude = fixmystreet.latitude;
args.longitude = fixmystreet.longitude;
@@ -159,8 +159,9 @@ $(function(){
timer = window.setTimeout(email_alert_close, 2000);
});
-
- $('#form_category').change( form_category_onchange );
+ // Using delegate here because we *might* be running under a cobrand which isn't jQuery 1.7+
+ // Delegation is necessary because #form_category may be replaced during the lifetime of the page
+ $("#problem_form").delegate("select#form_category", "change", form_category_onchange );
// Geolocation
if (geo_position_js.init()) {
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index a7b7d6a14..89c862847 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -432,11 +432,6 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
}, function(data) {
$('#councils_text').html(data.councils_text);
$('#form_category_row').html(data.category);
- /* Need to reset this here as it gets removed when we replace
- the HTML for the dropdown */
- if ( data.has_open311 > 0 ) {
- $('#form_category').change( form_category_onchange );
- }
});
$('#side-form, #site-logo').show();
diff --git a/web/js/southampton.js b/web/js/southampton.js
index 1f3e16105..c0fa48b06 100644
--- a/web/js/southampton.js
+++ b/web/js/southampton.js
@@ -15,13 +15,16 @@ $(function(){
}
}).blur(function(){
var input = $(this);
- if (input.val() == '' || input.val() == input.attr('placeholder')) {
+ if (input.val() === '' || input.val() == input.attr('placeholder')) {
input.css({ 'color': '#999999' });
input.val(input.attr('placeholder'));
}
}).blur();
-
- $('#form_category').change(function(){
+
+ // use on() here because the #form_category may be replaced
+ // during the page's lifetime
+ $("#problem_form").on("change.southampton", "select#form_category",
+ function() {
var category = $(this).val();
if ('Potholes' == category) {
if (!$('#potholes_extra').length) {
@@ -39,12 +42,13 @@ $(function(){
'<option>Deeper than a tennis ball' +
'</select></div></div>';
$('#form_title').closest('div.form-field').after(qns);
- }
+ }
$('#potholes_extra').show('fast');
} else {
$('#potholes_extra').hide('fast');
- }
- }).change();
+ }
+ }
+ ).change(); // change called to trigger (in case we've come in with potholes selected)
});