Yui3过渡隐藏并显示div

时间:2012-03-26 21:16:27

标签: javascript yui transition

我有以下代码段:

YUI().use('transition', 'node-event-delegate', function(Y) {
        var button = Y.one('#subscribe');
        var close = Y.one('#close');

        function open (e) {
            var node = Y.one('#popup-subscribe');
            node.show(true);
        }
        button.on('click', open);

        function closeIt (e) {
            var node = Y.one('#popup-subscribe');
            node.hide(true);
        }
        close.on('click', closeIt);
    });

但是当我测试它并点击关闭时,例如我收到此错误消息:

node.hide is not a function

node.hide(true);

知道为什么吗?

1 个答案:

答案 0 :(得分:0)

您可能需要向我们展示您的HTML,因为使用正确的javascript包含和适当的HTML,它在这里工作正常:http://jsfiddle.net/jfriend00/27fJW/。所以,我怀疑你要么没有正确的HTML,要么你没有正确的核心YUI包括。

我编写的HTML符合代码:

<script src="http://yui.yahooapis.com/3.4.1pr1/build/yui/yui-min.js"></script>

<button id="subscribe">Open</button>
<button id="close">Close</button>

<div id="popup-subscribe">Popup content</div>

您的代码(未更改):

YUI().use('transition', 'node-event-delegate', function(Y) {
    var button = Y.one('#subscribe');
    var close = Y.one('#close');

    function open (e) {
        var node = Y.one('#popup-subscribe');
        node.show(true);
    }
    button.on('click', open);

    function closeIt (e) {
        var node = Y.one('#popup-subscribe');
        node.hide(true);
    }
    close.on('click', closeIt);
});​
相关问题