Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit a5f8d66

Browse files
committed
bug(model): Touched value now set correctly.
Closes #206
1 parent b5e84f9 commit a5f8d66

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/tinymce.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ angular.module('ui.tinymce', [])
6262
ed.on('init', function() {
6363
ngModel.$render();
6464
ngModel.$setPristine();
65+
ngModel.$setUntouched();
6566
if (form) {
6667
form.$setPristine();
6768
}
@@ -81,6 +82,8 @@ angular.module('ui.tinymce', [])
8182

8283
ed.on('blur', function() {
8384
element[0].blur();
85+
ngModel.$setTouched();
86+
scope.$digest();
8487
});
8588

8689
// Update model when an object has been resized (table, image)

test/tinymce.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe('uiTinymce', function () {
3535
compile();
3636
expect(directiveElement.controller('form').$pristine).toBe(true);
3737
expect(directiveElement.controller('ngModel').$pristine).toBe(true);
38+
expect(directiveElement.controller('ngModel').$touched).toBe(false);
3839
});
3940

4041
describe('compiling this directive', function() {
@@ -65,6 +66,14 @@ describe('uiTinymce', function () {
6566
});
6667
});
6768

69+
it("should set touched on blur", function(){
70+
compile();
71+
expect(directiveElement.controller('ngModel').$touched).toBe(false);
72+
73+
element.find("textarea").triggerHandler("blur");
74+
expect(directiveElement.controller('ngModel').$touched).toBe(true);
75+
});
76+
6877
it('should remove tinymce instance on $scope destruction', function() {
6978
compile();
7079
expect(tinymce.get(element.attr('id'))).toBeDefined();

0 commit comments

Comments
 (0)