EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: cohoman on July 21, 2013, 04:34:48 PM



Title: Exiting tree control 'beginEdit' when clicking on a different tree item?
Post by: cohoman on July 21, 2013, 04:34:48 PM
I'm using the following to initiate in-line editing of a tree item label:

Code:
jQuery("#tree_control").tree( { onDblClick: function(node){ jQuery(this).tree('beginEdit',node.target); } });

This works fine. Currently, I have to press the "return" key my keyboard to exit editing mode. Is there a way to exit editing by clicking on a different tree item, or anywhere else on the tree? I tried to use the following call when clicking on a tree item, and my code fails to execute the function:

Code:
var selected_node = jQuery("#tree_control").tree('getSelected');    
jQuery("#tree_control").tree('endEdit',selected_node.id);      // - FAILS TO EXECUTE
jQuery("#tree_control").tree('endEdit',selected_node.target); // - FAILS TO EXECUTE

Your help is appreciated!

Thanks.


Title: Re: Exiting tree control 'beginEdit' when clicking on a different tree item?
Post by: stworthy on July 21, 2013, 11:49:05 PM
When the tree's editor loses focus, the 'endEdit' method will be called to finish the current editing action. You don't need to call 'endEdit' method again.


Title: Re: Exiting tree control 'beginEdit' when clicking on a different tree item?
Post by: cohoman on July 22, 2013, 09:32:05 PM
Thanks, but it doesn't seem to be working for me. I may have some listeners that could be intercepting that lose focus message maybe? In any case, can you explain how I can initiate the "endEdit" manually?

Thanks.