From 0eab4a2daf436f7c4f2693cdb5283d843d30fdaa Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 15 Mar 2010 21:27:06 +0000 Subject: [PATCH] MINOR Fixed PermissionCheckboxSetField.js checkbox toggling when no previous values have been saved through jQuery.data() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@101070 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/PermissionCheckboxSetField.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/javascript/PermissionCheckboxSetField.js b/javascript/PermissionCheckboxSetField.js index b141eb9ae..07fdc8dd5 100644 --- a/javascript/PermissionCheckboxSetField.js +++ b/javascript/PermissionCheckboxSetField.js @@ -24,8 +24,11 @@ }); } else { checkboxes.each(function() { - $(this).attr('checked', $(this).data('SecurityAdmin.oldChecked')); - $(this).attr('disabled', $(this).data('SecurityAdmin.oldDisabled')); + // only update attributes if previous values have been saved + var oldChecked = $(this).data('SecurityAdmin.oldChecked'); + var oldDisabled = $(this).data('SecurityAdmin.oldDisabled'); + if(oldChecked != null) $(this).attr('checked', oldChecked); + if(oldDisabled != null) $(this).attr('disabled', oldDisabled); }); } }