
// see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController
angular.module('palaso.ui.jqte', [])
	// jqte
	.directive('puiJqte', ['$parse', function($parse) {
		return {
			restrict: 'A',
			require: '?ngModel', // This causes the controller in the link function to be the ngModelController
			link: function(scope, element, attrs, ngModelCtrl) {
				if (!ngModelCtrl) {
					return;
				}
				ngModelCtrl.$render = function() {
					element.val(ngModelCtrl.$viewValue);
				};
				var options = scope[attrs.puiJqte] === undefined ? {} : scope[attrs.puiJqte];
				options.change = function() {
					var v = element.val();
					console.log('change', v);
					scope.$apply(read);
				}; 
				element.jqte(options);
				function read() {
					ngModelCtrl.$setViewValue(element.val());
				}
			}
		};
	}])
	;

@@ -435,24 +435,92 @@
 unction() %7B%0A
+%09%09%09%09%09var phase = scope.$$phase;%0A%09%09%09%09%09console.log('render ', phase);%0A
 %09%09%09%09%09element
@@ -520,17 +520,21 @@
 element.
-v
+jqteV
 al(ngMod
@@ -685,61 +685,62 @@
 %09%09%09%09
-var v = element.val();%0A%09%09%09%09%09console.log('change', v);
+if (scope.$$phase == '$digest') %7B%0A%09%09%09%09%09%09return;%0A%09%09%09%09%09%7D
 %0A%09%09%09
@@ -796,16 +796,28 @@
 tions);%0A
+%09%09%09%09read();%0A
 %09%09%09%09func

Fix ng-jqte directive that was not binding in both directions.