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

后端 未结 2 1860
轻奢々
轻奢々 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/

    0 讨论(0)
  • 2021-01-12 04:59

    There is another option missing, probably need to add the ui module, try this:

    j1("#utree_activity").jstree({ 
    "plugins" : ["html_data","ui"],
    
     //the rest of your code
    });
    
    0 讨论(0)
提交回复
热议问题