0
원하는 폴더에 노드를 추가하려고하지만 불행히도 성공하지 못했습니다. 아이디어는 간단합니다. 클릭 버튼 사용자는 modal을 보며 다음과 같은 몇 가지 매개 변수를 넣을 수 있습니다 : name과 description for node는 http 요청으로부터 동적으로 올 것입니다. 또한 노드를 저장할 폴더를 선택할 수 있습니다. 그러나 어떤 이유로 노드가 각 부모에 나타나고 있습니다. 폴더와 내 실수는 어디서 찾을 수 있습니까? 기능이 잘못 저장에새 폴더를 원하는 폴더에 추가하십시오.
(function() {
app.controller('HomeCtrl', ["$scope", "$rootScope", "$http", '$interval', '$q', "$log", "$routeParams", "$location", "$uibModal",
function($scope, $rootScope, $http, $interval, $q, $log, $routeParams, $location, $uibModal) {
$scope.tree_core = {
multiple: false, // disable multiple node selection
check_callback: function(operation, node, node_parent, node_position, more) {
// operation can be 'create_node', 'rename_node', 'delete_node', 'move_node' or 'copy_node'
// in case of 'rename_node' node_position is filled with the new node name
if (operation === 'move_node') {
return false; // disallow all dnd operations
}
return true; // allow all other operations
}
};
$scope.contextMenu = custom.contextMenu;
// *** Begin Callback Functions for Tree ***
// Describe callback function that to all necessary variables related with Jstree
$scope.callback = function(e, data) {
// ===== Click event on node for Industry =====
for (var i = 0; i < data.selected.length; i++) {
var parentNodeId = data.instance.get_node(data.selected[i]).parent;
var parentNodeText = data.instance.get_node(parentNodeId).text;
$scope.node = data.instance.get_node(data.selected[i]).text;
$scope.path = data.instance.get_path(data.node, '/');
}
};
// Declared initial folder
$scope.filters = custom.sharedFilter;
$scope.open = function() {
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'modal.html',
controller: 'EventFilterCtrl',
size: 'md',
resolve: {
items: function() {
return $scope.filters;
}
}
});
modalInstance.result.then(function(selectedItem) {
$scope.selected = selectedItem;
}, function() {
$log.info('Modal dismissed at: ' + new Date());
});
};
// Storing variable in localstorage later will moved to DB
// Data based on ui-modal and ui-grid callback functions
$rootScope.saveFilter = function() {
var $saveForm = $('#filter-save-form');
var filterName = $saveForm.find('#filter-save-name').val();
var filterDescription = $saveForm.find('#filter-save-description').val();
$scope.item = {
"text": filterName,
"description": filterDescription,
"value": Date.now(),
};
var i = 0;
for (i; i < $scope.filters.length; i++) {
if ($scope.filters[i]) {
console.log("pass");
$scope.filters[i].children.push($scope.item)
}
}
};
// ==== End Build Left Bar =====
}
]);
}());
좋은 사람 : 당신은 내가 당신의 plunker를 포크
올바른 폴더에 새 항목을 추가하고 수정 모달에 선택된 노드를 얻을 수 및 저장 기능에 넣어 정확한 상태를 구현해야합니다 ! 그것이 말하는 한 가지만 정의되지 않은 'text'속성을 읽을 수는 없지만 함께 작업 할 수 있습니다. – Anton