I'm using fancytree.js i want to alert a message when i clic on a node. but not all nodes. Just when clicking on the nodes in the 2nd level. Example
<ul> <li>1</li> <ul> <li>1.1</li> <li>1.2</li> </ul> <li>2</li> <ul> <li>1.1</li> <li>1.2</li> </ul> <li>3</li> </ul>
i want just alert when on clicking on 1.1 and 1.2 or 2.1 and 2.2
$(document) . ready(function () {
var data = '{{ path('gouvernorat_map') }}';
$("#filter_switches") . fancytree({
source: {
url:data
},
icon: false,
keyboard: true,
quicksearch: false,
tooltip: false,
click: function (event, data) {
alert(data . node + '---' + data . node . key + '---' + data . node . title + '---');
}
});
});
this alert when i click in any level. so how can i did it?
you can ask the level from any node by using data.node.getLevel()
. If you put this into an if-statement, you can filter by level.
For more information, see the documentation of fancytree
Good luck
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.