{"action":"created","issue":{"url":"https://api.github.com/repos/valor-software/ng2-dragula/issues/487","repository_url":"https://api.github.com/repos/valor-software/ng2-dragula","labels_url":"https://api.github.com/repos/valor-software/ng2-dragula/issues/487/labels{/name}","comments_url":"https://api.github.com/repos/valor-software/ng2-dragula/issues/487/comments","events_url":"https://api.github.com/repos/valor-software/ng2-dragula/issues/487/events","html_url":"https://github.com/valor-software/ng2-dragula/issues/487","id":194926607,"number":487,"title":"prevent container from dopping into itself","user":{"login":"Err0r500","id":24520691,"avatar_url":"https://avatars.githubusercontent.com/u/24520691?v=3","gravatar_id":"","url":"https://api.github.com/users/Err0r500","html_url":"https://github.com/Err0r500","followers_url":"https://api.github.com/users/Err0r500/followers","following_url":"https://api.github.com/users/Err0r500/following{/other_user}","gists_url":"https://api.github.com/users/Err0r500/gists{/gist_id}","starred_url":"https://api.github.com/users/Err0r500/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Err0r500/subscriptions","organizations_url":"https://api.github.com/users/Err0r500/orgs","repos_url":"https://api.github.com/users/Err0r500/repos","events_url":"https://api.github.com/users/Err0r500/events{/privacy}","received_events_url":"https://api.github.com/users/Err0r500/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-12T09:31:00Z","updated_at":"2016-12-12T11:28:41Z","closed_at":null,"body":"Hello,\r\nI built a nested tree view and its working quite well (thanks!), except on specific \"moves\" where I got this error message : \r\n`Uncaught HierarchyRequestError: Failed to execute 'insertBefore' on 'Node': The new child element contains the parent. ` \r\n\r\nThen the container becomes a sort of black hole : everything dropped in disappears.\r\n\r\nI found this closed issue : https://github.com/bevacqua/dragula/issues/52 but wasn't able to replicate the workaround with angular 2.\r\nIs there a way to disable temporarily a container from dropping into itself ? (if it's the real problem)\r\nThanks,\r\nBest,\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/valor-software/ng2-dragula/issues/comments/266405425","html_url":"https://github.com/valor-software/ng2-dragula/issues/487#issuecomment-266405425","issue_url":"https://api.github.com/repos/valor-software/ng2-dragula/issues/487","id":266405425,"user":{"login":"Err0r500","id":24520691,"avatar_url":"https://avatars.githubusercontent.com/u/24520691?v=3","gravatar_id":"","url":"https://api.github.com/users/Err0r500","html_url":"https://github.com/Err0r500","followers_url":"https://api.github.com/users/Err0r500/followers","following_url":"https://api.github.com/users/Err0r500/following{/other_user}","gists_url":"https://api.github.com/users/Err0r500/gists{/gist_id}","starred_url":"https://api.github.com/users/Err0r500/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Err0r500/subscriptions","organizations_url":"https://api.github.com/users/Err0r500/orgs","repos_url":"https://api.github.com/users/Err0r500/repos","events_url":"https://api.github.com/users/Err0r500/events{/privacy}","received_events_url":"https://api.github.com/users/Err0r500/received_events","type":"User","site_admin":false},"created_at":"2016-12-12T11:28:41Z","updated_at":"2016-12-12T11:28:41Z","body":"Ok, this seems to work for now : \r\nBest,\r\n```\r\nconstructor(private dragulaService: DragulaService) {\r\n    dragulaService.setOptions('first-bag', {\r\n      accepts: function (el, target, source, sibling) {\r\n        return target.className !== 'moving';\r\n      },\r\n    });\r\n\r\n    dragulaService.drag.subscribe((value) => {\r\n      this.lockChildrenContainers(true, value.slice(1)[0]);\r\n    });\r\n\r\n    dragulaService.dragend.subscribe((value) => {\r\n      this.lockChildrenContainers(false, value.slice(1)[0]);\r\n    });\r\n\r\n    dragulaService.dropModel.subscribe((value) => {\r\n      this.lockChildrenContainers(false, value.slice(1)[0]);\r\n\r\n    });\r\n  }\r\n\r\n  private lockChildrenContainers(lock:boolean, el:any){\r\n    let initialState, finalState:string;\r\n    if(lock){\r\n      initialState = \"container\";\r\n      finalState = \"moving\";\r\n    }\r\n    else{\r\n      initialState = \"moving\";\r\n      finalState = \"container\";\r\n    }\r\n\r\n    let childrenContainers = el.getElementsByClassName(initialState); //maybe build a better function ?\r\n    for(let i = 0; i < childrenContainers.length; i++){\r\n      childrenContainers[i].className = finalState;\r\n    }\r\n  }\r\n```"}}
{"actor":{"display_login":"Err0r500"}}