diff --git a/src/json-formatter.js b/src/json-formatter.js index cb92b5c..3ab4f9b 100644 --- a/src/json-formatter.js +++ b/src/json-formatter.js @@ -153,6 +153,13 @@ angular.module('jsonFormatter', ['RecursionHelper']) // If 'open' attribute is present scope.isOpen = !!scope.open; scope.toggleOpen = function () { + if (!scope.$parent.$parent.$parent.selected) { + scope.$parent.$parent.$parent.selected = scope; + } + if (scope.$parent.$parent.$parent.selected.$id != scope.$id) { + scope.$parent.$parent.$parent.selected.isOpen = false; + scope.$parent.$parent.$parent.selected = scope; + } scope.isOpen = !scope.isOpen; }; scope.childrenOpen = function () { @@ -226,4 +233,4 @@ angular.module('jsonFormatter', ['RecursionHelper']) // angular.module('myApp', [require('jsonformatter')]); if (typeof module === 'object') { module.exports = 'jsonFormatter'; -} \ No newline at end of file +}