开发者

How do I assign custom classes to YUI3 plugin/widget objects

开发者 https://www.devze.com 2023-02-21 13:48 出处:网络
Consider the following code. var overlay = new Y.Overlay({ id:\'tooltip-tag\', bodyContent:\"Loading.....\",

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:

  1. Add the class in your markup. I'm guessing this isn't what you want.
  2. Subclass Overlay and add a className config attribute. If you have other customization to do, this is an attractive option.
  3. Hook the overlay:render event and attach the class there. Here's a jsfiddle that demonstrates this technique: http://jsfiddle.net/4zN5M/1/
0

精彩评论

暂无评论...
验证码 换一张
取 消