From: Coleman Watts Date: Sun, 8 Mar 2015 02:27:36 +0000 (-0500) Subject: CRM-14353 - Fix unsavedChanges js to support checkboxes & radios X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=603f899a3fbae2cac497fbb3c4e4bda9b0bba17e;p=civicrm-core.git CRM-14353 - Fix unsavedChanges js to support checkboxes & radios --- diff --git a/js/Common.js b/js/Common.js index 737bc89fa0..bd5227f8e3 100644 --- a/js/Common.js +++ b/js/Common.js @@ -316,9 +316,11 @@ CRM.strings = CRM.strings || {}; CRM.utils.initialValueChanged = function(el) { var isDirty = false; $(':input:visible, .select2-container:visible+:input.select2-offscreen', el).not('[type=submit], [type=button], .crm-action-menu').each(function () { - var initialValue = $(this).data('crm-initial-value'); + var + initialValue = $(this).data('crm-initial-value'), + currentValue = $(this).is(':checkbox, :radio') ? $(this).prop('checked') : $(this).val(); // skip change of value for submit buttons - if (initialValue !== undefined && !_.isEqual(initialValue, $(this).val())) { + if (initialValue !== undefined && !_.isEqual(initialValue, currentValue)) { isDirty = true; } }); @@ -729,7 +731,7 @@ CRM.strings = CRM.strings || {}; $('select.crm-chain-select-control', e.target).off('.chainSelect').on('change.chainSelect', chainSelect); // Cache Form Input initial values $('form[data-warn-changes] :input', e.target).each(function() { - $(this).data('crm-initial-value', $(this).val()); + $(this).data('crm-initial-value', $(this).is(':checkbox, :radio') ? $(this).prop('checked') : $(this).val()); }); }) .on('dialogopen', function(e) {