diff --git a/angular-redactor.js b/angular-redactor.js index caac80b..66b7ab2 100644 --- a/angular-redactor.js +++ b/angular-redactor.js @@ -1,6 +1,5 @@ (function () { 'use strict'; - /** * usage: * @@ -16,10 +15,13 @@ link: function (scope, element, attrs, ngModel) { var updateModel = function updateModel(value) { - scope.$apply(function () { - ngModel.$setViewValue(value); - }); - }, + /* fix for html code view in redactor v9.2.1+ */ + if(element.not(':visible')) { + scope.$apply(function () { + ngModel.$setViewValue(value); + }); + } + }, options = { changeCallback: updateModel }, @@ -30,8 +32,7 @@ angular.extend(options, additionalOptions); - // put in timeout to avoid $digest collision. call render() to - // set the initial value. + // put in timeout to avoid $digest collision. call render() to set the initial value. $timeout(function () { editor = $_element.redactor(options); ngModel.$render(); @@ -41,6 +42,7 @@ if (angular.isDefined(editor)) { $timeout(function() { $_element.redactor('set', ngModel.$viewValue || ''); + ngForm.$setPristine(); }); } };