This is a migrated thread and some comments may be shown as answers.

[Solved] Selective Click - Click only on leafs, not on nodes

2 Answers 49 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arek
Top achievements
Rank 1
Arek asked on 27 Sep 2011, 12:46 PM
Hello,

I'm testing your MVC TreeView. The problem I have is easy (at least I hope).  I need a way to get Clicks on the leafs - not on the nodes. Every expandable element should not raise click function and every not expandable one should. Although it seems easy, I cannot find a way to do.

Regards
Arek B.

2 Answers, 1 is accepted

Sort by
0
aasda
Top achievements
Rank 1
answered on 08 Oct 2011, 09:43 PM
function TreeView_onChecked(e) {
   if ($(e.item).has('ul').length > 0) { //if node has leafs
            e.preventDefault(); //cancel checking
        } else {
            //your code here
        }
}

this should do the trick
0
Arek
Top achievements
Rank 1
answered on 11 Oct 2011, 07:03 AM
I'm using loading on demand so your code work when the items are loaded but until then it doesnt. The "user code" is executed when the not loaded node is clicked or if the node is loaded and it has nodes and leafs as its children so the code you've wrote is not exacly what I'm looking for but thank you for your time.

Regards,
Arek B.
Tags
TreeView
Asked by
Arek
Top achievements
Rank 1
Answers by
aasda
Top achievements
Rank 1
Arek
Top achievements
Rank 1
Share this question
or