jstree select_limit not working. I want to set selection limit to select only 3 nodes

后端 未结 2 1880
轻奢々
轻奢々 2021-01-12 04:01

My jstree function is here.
I have set \'select_limit\' : 3, but is not working. when I run, I am able to select more than 3 nodes, but I need to select no

2条回答
  •  自闭症患者
    2021-01-12 04:57

    select_limit doens't handle checkbox you must roll your own before.jstree method.

    j1.bind("before.jstree", function (e, data) {
        if (data.func === "check_node") {
            if (j1.jstree('get_checked').length >= 1) {
                e.preventDefault();
                return false;                
            }
        }
    });
    

    Note that this code if for example only, and doesn't handle child nodes

    Working fiddle: http://jsfiddle.net/cfb9J/1/

提交回复
热议问题