need help with several questions about jquery.jstree.js
How to get the currently selected node when click a button?
('#tree').jstree({...});
('#button').click(function(){ :selected_node? })
How to refresh a node when clic开发者_开发问答k a button?
('#tree').jstree({...});
('#button').click(function(){ :refresh? })
I would like to pop up a window to confirm a node is deleted. If 'cancel' is selected, the node should not be deleted. Whether can I do that and how?
Thanks a lot.
I suspect this will depend a little on which jstree plugin you are using to generate the tree. I'm using the HTML plugin and achieve the confirmation requirement as follows.
For each row there is a set of icons to perform various tasks on the tree each has a class of icon
and a further class to identify the action, for example:
<li class="row" id="26">
<a href="/admin/pages/add-edit/?pageId=26" class="treeLink">Home Page</a>
<div class="iconRow">
<a class="icon icon-tick" title="Active">Active</a>
<a href="/admin/pages/move/?pageId=26&direction=up" class="icon icon-arrow-up" title="Move Up">Move Up</a>
<a href="/admin/pages/move/?pageId=26&direction=down" class="icon icon-arrow-down" title="Move Down">Move Down</a>
<a href="/admin/pages/add-edit/?pageId=26" class="icon icon-page-edit" title="Edit">Edit</a>
<a href="/admin/pages/delete/?pageId=26" class="icon icon-page-delete" title="Delete">Delete</a>
</div>
</li>
So from here my jQuery code looks something like:
$('a.icon').live('click' ,function() { if ($(this).hasClass('icon-arrow-up') || $(this).hasClass('icon-arrow-down')) { //Do something here.... }
if ($(this).hasClass('icon-page-delete')) {
//Add confirmation box code here
}
return false; });
This is quite a simplistic look at it but hopefully will get you started on the way.
精彩评论