GithubHelp home page GithubHelp logo

Comments (6)

NickHi avatar NickHi commented on June 1, 2024 1

How to verify whether it is a node after clicking?
I just want to select child.

from jqtree.

mbraak avatar mbraak commented on June 1, 2024 1

Jqtree adds a jqtree-loading css class to the node when data is loading. Maybe you can do the same.

from jqtree.

mbraak avatar mbraak commented on June 1, 2024

This example only allows the selection of child nodes. It uses the tree.click event. Also see https://mbraak.github.io/jqTree/#event-tree-click

const $tree = $("#tree1");

$tree.tree({
    data: ExampleData.exampleData,
    selectable: true,
});

$tree.on("tree.click", (e) => {
    const node = e.node;

    if (node.children.length >= 1) {
        // You can prevent selection using preventDefault
        e.preventDefault();
    } else {
        console.log("child");
    }
});

from jqtree.

NickHi avatar NickHi commented on June 1, 2024

I want the loading state to be displayed before the current node
I don't know what to do with it

$tree.on( 'tree.click', function(e) {
	var _Node = e.node;
	if(_Node.ajaxState){
		$tree.tree('selectNode',_Node);
		return false;
	}else{
		$.ajax({
			type: "POST",
			url: "http://*****/search.php",
			data: {
				act:'list',
				id: _Node.id
			},
			dataType: "json",
			success: function(json){
				if(json.state=='success'){
					_Node['ajaxState'] = true;
					$tree.tree('updateNode',_Node,_Node);
					for(var i=0; i<json.res.length; i++){
						$tree.tree('appendNode',json.res[i],_Node);
					}
					$tree.tree('openNode',_Node);
				}else{
					alert(json.des);
				}
			}
		});
	}
})

from jqtree.

mbraak avatar mbraak commented on June 1, 2024

What does this code do? Does it execute some action on the server when a node is clicked?

from jqtree.

NickHi avatar NickHi commented on June 1, 2024

What does this code do? Does it execute some action on the server when a node is clicked?

Click and load the child node

from jqtree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.