Multiplay Labs

tech hits and tips from Multiplay

Archive for the ‘treeview’ tag

YUI Treeview editComplete event

without comments

While using YUI‘s excellent little treeview library I needed the ability to hook into the completion of the edit node event. This isnt present in 2.6.0 so came up with this little patch to add it:

Index: docs/yui/treeview/treeview.js
===================================================================
--- docs/yui/treeview/treeview.js	(revision 214)
+++ docs/yui/treeview/treeview.js	(working copy)
@@ -306,6 +306,15 @@
         this.createEvent("enterKeyPressed", this);
 
     /**
+         * Fires when the edit of a node is complete
+         * @event editComplete
+         * @type CustomEvent
+         * @param {YAHOO.widget.Node} node the node that has the focus
+         * @param {Boolean} true if the editor saved, false otherwise
+         */
+        this.createEvent("editComplete", this);
+
+    /**
          * Fires when the label in a TextNode or MenuNode or content in an HTMLNode receives a Click.
 	* The listener may return false to cancel toggling and focusing on the node.
          * @event clickEvent
@@ -3052,9 +3061,11 @@
 		if (save) {
 			ed.node.saveEditorValue(ed);
 		}
+
 		Dom.setStyle(ed.editorPanel,'display','none');
 		ed.active = false;
 		node.focus();
+		this.fireEvent( 'editComplete', node, save );
 	};
 
 	/**

Written by Dilbert

February 21st, 2009 at 11:35 pm

Posted in Hackery

Tagged with , , ,