0

我想知道是否可以使用这样的 onclick 事件设置和打开 YUI 面板:

<a href="#" onclick="myPanel = new YAHOO.widget.Panel("myPanel"); 
myPanel.setHeader('Header'); myPanel.setBody('Body'); 
myPanel.setFooter('Footer'); myPanel.render('document.body'); 
myPanel.show();"></a>
4

1 回答 1

0

要从另一个元素的单击事件中显示面板,您需要:创建面板,将其隐藏(使用visible: false),然后show()从单击事件处理程序中显示。这是一个例子:

var panel = new Y.Panel({
    bodyContent: 'foo',
    centered: true,
    width: 200,
    height: 100,
    visible: false //render the panel, but keep it hidden
});
panel.render();

// show the panel with a click
Y.one('#foo').on('click', function () {
    panel.show();
});
于 2012-06-21T22:54:56.490 回答