0

I'm making use of jsTree, and I'm trying to have a nested checkbox tree structure. Like so:

[] Parent 1
 [] Child 1
 [] Child 2

Parent 1 has an Id of 1 and Child 1 has an Id of 1, jsTree doesn't like that (it doesn't work), how can I tell jsTree that the nested (Child) tree has a separate list of Ids?

JsFiddle: https://jsfiddle.net/0jL272nx/7/

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Rian Mostert
  • 714
  • 1
  • 7
  • 19
  • 4
    This isn't a jsTree issue - it's a HTML issue. You cannot have duplicate `id` attributes within the DOM. Their entire point is to uniquely identify entities, which is not possible if you duplicate them. – Rory McCrossan Feb 26 '18 at 16:17
  • Thanks @RoryMcCrossan, that does make sense, but it doesn't answer the question and it's definitely not a duplicate of "Does ID have to be unique in the whole page?" – Rian Mostert Feb 26 '18 at 16:24
  • 1
    The answer is 'use unique ids'. – Rory McCrossan Feb 26 '18 at 16:26
  • @RoryMcCrossan, changing the data isn't a solution, it seems it might be possible by supplying the data as json and having the jsTree handle the Id. Never give up, there's a solution out there somewhere. – Rian Mostert Feb 26 '18 at 16:34
  • Fair point. I've reopened the question for you as it wasn't technically a dupe, although hopefully gave you an understanding of why duplicate `id` attributes cannot work. I'll advise you though, what you're trying to do is very much 'the hard way' when far easier is available. – Rory McCrossan Feb 26 '18 at 16:35
  • 1
    [This](https://github.com/vakata/jstree/issues/592) guy had the same question, which received the same answer as @RoryMcCrossan gave – GalAbra Feb 26 '18 at 16:38

0 Answers0