diff --git a/static/js/settings_org.js b/static/js/settings_org.js index ab0da0659c..3918b99240 100644 --- a/static/js/settings_org.js +++ b/static/js/settings_org.js @@ -492,34 +492,32 @@ function _set_up() { } }); - function discard_subsection_changes(target) { - _.each(get_subsection_property_elements(target), function (elem) { - elem = $(elem); - var property_name = exports.extract_property_name(elem); - // Check whether the id refers to a property whose name we can't - // extract from element's id. - var property_value = property_value_element_refers(property_name); - if (property_value === undefined) { - property_value = page_params[property_name]; - } + function discard_property_element_changes(elem) { + elem = $(elem); + var property_name = exports.extract_property_name(elem); + // Check whether the id refers to a property whose name we can't + // extract from element's id. + var property_value = property_value_element_refers(property_name); + if (property_value === undefined) { + property_value = page_params[property_name]; + } - if (typeof property_value === 'boolean') { - elem.prop('checked', property_value); - } else if (typeof property_value === 'string' || typeof property_value === 'number') { - elem.val(property_value); - } else { - blueslip.error('Element refers to unknown property ' + property_name); - } - // Triggering a change event to handle fading and showing of - // dependent sub-settings correctly - elem.change(); - }); + if (typeof property_value === 'boolean') { + elem.prop('checked', property_value); + } else if (typeof property_value === 'string' || typeof property_value === 'number') { + elem.val(property_value); + } else { + blueslip.error('Element refers to unknown property ' + property_name); + } + // Triggering a change event to handle fading and showing of + // dependent sub-settings correctly + elem.change(); } $('.organization').on('click', '.subsection-header .subsection-changes-discard button', function (e) { e.preventDefault(); e.stopPropagation(); - discard_subsection_changes(e.target); + _.each(get_subsection_property_elements(e.target), discard_property_element_changes); var subsection = $(e.target).closest('.org-subsection-parent'); var change_process_buttons = subsection.find('.subsection-header .button'); change_process_buttons.removeClass('show').addClass('hide');