How do I assign custom classes to YUI3 plugin/widget objects
Consider the following code.
var overlay = new Y.Overlay({
id:'tooltip-tag',
bodyContent:"Loading.....",
xy:[e.target.getX(),e.target.getY()+30]
});
The overlay gets the id as given in attributes. But what if I want to add a class ?
IS there so开发者_高级运维mething like:
var overlay = new Y.Overlay({
**class:'tooltip-tag'**,
bodyContent:"Loading.....",
xy:[e.target.getX(),e.target.getY()+30]
});
No. Here are three ways to do what you want:
- Add the class in your markup. I'm guessing this isn't what you want.
- Subclass Overlay and add a
className
config attribute. If you have other customization to do, this is an attractive option. - Hook the
overlay:render
event and attach the class there. Here's a jsfiddle that demonstrates this technique: http://jsfiddle.net/4zN5M/1/
精彩评论