From 603f899a3fbae2cac497fbb3c4e4bda9b0bba17e Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 7 Mar 2015 21:27:36 -0500 Subject: [PATCH] CRM-14353 - Fix unsavedChanges js to support checkboxes & radios --- js/Common.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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) { -- 2.25.1