Search code examples
javascriptfancytree

Extra node rendering is gone when node's title is edited


In renderNode event handler I add a button to node.span as follows:

 renderNode: function (event, data) {
   var node = data.node;
   var buttons = $('<button type="button" title="info" onclick="info(\'' + node.key + '\')" class="infobtn">i</button>');
   $(node.span).append(buttons);
 }

The Fancytree I am using has the 'edit' extension enabled. When I edit a node title - even if I don't change the title at all - the defined button is gone.

Is there a way to keep the added button? Or should I add it again in the 'edit' extension's save event handler?


Solution

  • The filter and edit extensions reset the node's markup, so you have to re-apply your extension in the respective callbacks.

    Note that release 2.18+ will introduce a new callback enhanceTitle() to make this easier.