PDA

View Full Version : toolbar addButton



mimiz
15 Jan 2007, 9:33 AM
Hi,
I'm using a toolbar to do actions on different elements on my page,


var lineTb = new YAHOO.ext.Toolbar(getEl("line-"+id));
ligneTb.addButton(
{
text:"./images/delete.png",
className:'toolbar-btn delete',
tooltip:"delete element",
click:function(){
HERE
}
}
);

i just want to know how i can retreive element behind cusrsor when i click my button ...
all my "line"s elements are div element ...
if i do something like
e.target it doesn't work ...
Don't know if i am clear ...
thanks
mimiz

tryanDLS
15 Jan 2007, 9:50 AM
When your click fn is called, the 1st arg is the button. However, it's an Element, not a Dom object, so e.Target isn't going to be valid.

Stop in that code with Firebug and look at the object to see what's there. Refer to the doc for Element to see what methods/properties are available. http://yui-ext.com/deploy/yui-ext/docs/output/YAHOO.ext.Element.html

Also, you may want to add 'scope:this' to your button config, depending on what you need to do in the click handler.