following is my code :
var nodeData = ${jsonArray}; // my json data
$('#tree1')
.tree(
{
data : nodeData,
autoOpen : 1,
onCreateLi : function(node, $li) {
$li
.find('.jqtree-element')
.append(
'<a href="javascript:void(0);" class="delete" data-node-id="Test"><i class="ico ico-tool-delete"></i></a>');
}
});
$('#tree1').bind('tree.click', function(event) {
if (event.node) {
var node = event.node;
alert("edit");
}
$tree.on('click', '.Test', function(e) {
alert("delete");
});
});
I want to generate different event when click on node and delete icon.
Currently when I click on node and delete icon both generate same event.
Help me, which changes required in above code.
thanks
First you are trying to select elements with
classTest but this class is not existing.Also the delete icon is inside the
linodes elements this is why you get the same event fired.Try to append the delete
aelement like this:check fiddle
Edit:
you can save the node id as data
attributewhile appending the delete element. Then when you click on a specific delete element get the required node by id:Then remove this item:
new fiddle