jsTree asynchronous search - trigger load new nodes

前端 未结 1 906
长情又很酷
长情又很酷 2020-12-19 22:30

I have a nicely running implementation of jsTree running on a project of mine. The JSON data is provided by PHP/Ajax. I\'ve run into some trouble while using the search plug

相关标签:
1条回答
  • 2020-12-19 22:47

    I've figured this out. My problem was that I was returning multiple arrays containing the path to each matched node like this:

    Array(
        Array('#root', '#child', '#sub-child'),
        Array('#root', '#child', '#second-sub')
    )
    

    As it turns out, jsTree's search plugin A only expects a single-level array, and B will load all nodes listed in that array, the path order doesn't have to be perfectly accurate like the documentation might suggest.

    So instead, in my JSON I'm returning an array containing unique node IDs like this:

    Array( '#root', '#child', '#sub-child', '#second-sub' )
    

    ...and the search plugin is loading the nodes as expected.

    Nothing fancy in the end, but I think the jsTree documentation should be more descriptive on this matter as I've seen others with the same problem and no answers.

    0 讨论(0)
提交回复
热议问题