Skip to content

Commit 4efc9ed

Browse files
committed
bugfix: don’t re-add and compile editors
- this fix is twofold: first it keeps the compiled editor on the scope as we don’t need to re-compile a new editor every time - secondly it tracks the editing state on the scope as well for the next feature using the down arrow
1 parent 98f929a commit 4efc9ed

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

grid_directives.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,21 @@ angular.module("app").directive("editorInitializer", function($compile, $templat
9494
restrict: 'E',
9595
templateUrl: '/templates/editor_initializer.html',
9696
controller: function($scope) {
97+
$scope.editing = false;
9798
$scope.edit = function(row) {
9899
$scope.$broadcast('edit', row);
99100
};
100101
},
101102
link: function(scope, element, attributes) {
102103
scope.$on('edit', function(e, row) {
103-
var editor = $compile($templateCache.get("/templates/editor.html"))(scope);
104-
$(editor).insertAfter(element.parents("tr"));
104+
scope.editing = !scope.editing;
105+
$(element.parents("tr")).toggleClass("editing", scope.editing);
106+
if(scope.editing) {
107+
scope.editor = scope.editor || $compile($templateCache.get("/templates/editor.html"))(scope);
108+
$(scope.editor).insertAfter(element.parents("tr"));
109+
} else {
110+
$(scope.editor).remove();
111+
}
105112
});
106113
console.log('linked editorInitializer');
107114
}

0 commit comments

Comments
 (0)