linjingming / sim-tree

一个操作简单的基于jquery的树展示插件,支持异步展示子节点
MIT License
24 stars 3 forks source link

[SOLVED] "checked":"checked" causing error for hierarchical trees #9

Open answerquest opened 4 years ago

answerquest commented 4 years ago
jquery-3.3.1.min.js:2 Uncaught Error: Syntax error, unrecognized expression: [data-id=VeeVee Cabs]
    at Function.oe.error (jquery-3.3.1.min.js:2)
    at oe.tokenize (jquery-3.3.1.min.js:2)
    at Function.oe [as find] (jquery-3.3.1.min.js:2)
    at w.fn.init.find (jquery-3.3.1.min.js:2)
    at String.<anonymous> (simTree.js:1)
    at Function.each (jquery-3.3.1.min.js:2)
    at e.setSelected (simTree.js:1)
    at e.doRender (simTree.js:1)
    at e.render (simTree.js:1)
    at e.init (simTree.js:1)
oe.error @ jquery-3.3.1.min.js:2
oe.tokenize @ jquery-3.3.1.min.js:2
oe @ jquery-3.3.1.min.js:2
find @ jquery-3.3.1.min.js:2
(anonymous) @ simTree.js:1
each @ jquery-3.3.1.min.js:2
setSelected @ simTree.js:1
doRender @ simTree.js:1
render @ simTree.js:1
init @ simTree.js:1
e @ simTree.js:1
e @ simTree.js:1
complete @ allMap.js:120
parseChunk @ papaparse.min.js:7
_chunkLoaded @ papaparse.min.js:7
(anonymous) @ papaparse.min.js:7
load (async)
_readChunk @ papaparse.min.js:7
_nextChunk @ papaparse.min.js:7
stream @ papaparse.min.js:7
parse @ papaparse.min.js:7
loadVehiclesLookup @ allMap.js:85
(anonymous) @ allMap.js:63
l @ jquery-3.3.1.min.js:2
c @ jquery-3.3.1.min.js:2
setTimeout (async)
(anonymous) @ jquery-3.3.1.min.js:2
u @ jquery-3.3.1.min.js:2
fireWith @ jquery-3.3.1.min.js:2
fire @ jquery-3.3.1.min.js:2
u @ jquery-3.3.1.min.js:2
fireWith @ jquery-3.3.1.min.js:2
ready @ jquery-3.3.1.min.js:2
_ @ jquery-3.3.1.min.js:2

Upon adding "checked": "checked" setting to either parent or child nodes, this error happens and only the first node is checked; the error prevents from checking the other nodes.

answerquest commented 4 years ago

Hi, update: I found a workaround. After your simTree is made and ready, run these lines in JS for all the parent nodes you want checked:

document.querySelector(`#tree > ul > li:nth-child(1) > a`).click();

loop the number in nth-child(1) from 1 to n (or do selectively - you should know the order in which your parent nodes are).