PDA

View Full Version : basic question...



genius551v
20 Nov 2006, 8:44 AM
Hi,

can you helpme whit this:

i have this code:


<html>
<head>
<title>Menú</title>

<script language="JavaScript" src="web/js/yui.js"></script>
<script language="JavaScript" src="web/js/tree/treeview.js"></script>
<script language="JavaScript" src="web/js/tree/menutree.js"></script>
</head>

<body>
<div id="menutree"></div>
</body>
</html>

this is a menu tree used the treeview.js yahoo

ok, that is ok no problem

but i need subscribe a method LABELCLICK, i have this code: (menutree.js) ->es el q pinta el arbol<-


var menutree = function(){
var tree;

return {
init: function(){
tree = new YAHOO.widget.TreeView('menutree');
tree.setExpandAnim(YAHOO.widget.TVAnim.FADE_IN);
tree.setCollapseAnim(YAHOO.widget.TVAnim.FADE_OUT);

colecciones = new YAHOO.widget.TextNode('COLECCIONES', tree.getRoot(), false);

myobj = {label: 'Colección 1'};
coleccion1 = new YAHOO.widget.TextNode(myobj, colecciones, false);

myobj = {label: 'MARCA1'};
marca1 = new YAHOO.widget.TextNode(myobj, coleccion1, false);

myobj = {label: 'MARCA2'};
marca2 = new YAHOO.widget.TextNode(myobj, coleccion1, false);

tree.subscribe("onLabelClick", function(node) {
alert("label was clicked");
});

tree.draw();
var callback = null;
}
};
}();
YAHOO.util.Event.on(window, 'load', menutree.init, menutree, true);


SUBSCRIBE DONT WORKS :cry:

can you tell me what a i missed??

Subscribe function is a e.g from yahoo

Note: setExpandAnim and setCollapseAnim works ok.

Tnks

Animal
20 Nov 2006, 9:11 AM
There is no OnLabelClick CustomEvent in TreeView.

Docs: http://www.yui-ext.com/docs/output/YAHOO.widget.TextNode.html#labelClick

genius551v
20 Nov 2006, 9:31 AM
labelClick:



tree.subscribe("labelClick", function(node) {
alert("label was clicked");
});


still dont works

:cry:

Animal
20 Nov 2006, 10:17 AM
"tree"?

Did you actually go to the terrible trouble of following that link????

arnair
20 Nov 2006, 11:54 AM
:) I think what Animal's trying to say is that the event is on the *node* (as indicated by his link) and not on the tree, so you need to subscribe to each node. Guess you may have missed that.