From 63aa303673caef10f40b19d30b81472e8f8c7b2f Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Fri, 28 Feb 2014 10:19:19 +0000 Subject: [PATCH] Fix form sometimes read-only on refresh --- .../META-INF/resources/admin/js/app.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js index 3ec70c29e0..1e34e1714e 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js @@ -814,12 +814,19 @@ module.directive('kcReadOnly', function() { var d = { replace : false, link : function(scope, element, attrs) { - if (scope.$eval(attrs.kcReadOnly)) { - element.find('input').attr('disabled', 'disabled'); - element.find('button').attr('disabled', 'disabled'); - element.find('select').attr('disabled', 'disabled'); - element.find('textarea').attr('disabled', 'disabled'); - } + scope.$watch(attrs.kcReadOnly, function(readOnly, oldValue) { + if (readOnly) { + element.find('input').attr('disabled', 'disabled'); + element.find('button').attr('disabled', 'disabled'); + element.find('select').attr('disabled', 'disabled'); + element.find('textarea').attr('disabled', 'disabled'); + } else { + element.find('input').removeAttr('disabled'); + element.find('button').removeAttr('disabled'); + element.find('select').removeAttr('disabled'); + element.find('textarea').removeAttr('disabled'); + } + }); } }; return d;