tags:

views:

39

answers:

1
+1  Q: 

YUI 2 in 3 locally

Hi, I am new to YUI and I want to load YUI 2 in 3 locally, not from CDN. I have pasted both 2 and 3 in same directory named Scripts. I am pasting my code below:

<script type="text/javascript" src="/Scripts/build-yui3/yui/yui-min.js"></script>

function showError(panelId) {
    YUI({
groups: {
    yui2: {
        base: '/build-yui2/',

        // If you have a combo service, you can configure that as well
        // combine: true,
        // comboBase: 'http://myserver.com/combo?',
        // root: '/2in3/build/',

        patterns:  { 
            'yui2-': {
                configFn: function(me) {
                    if(/-skin|reset|fonts|grids|base/.test(me.name)) {
                        me.type = 'css';
                        me.path = me.path.replace(/\.js/, '.css');
                        me.path = me.path.replace(/\/yui2-skin/, '/assets/skins/sam/yui2-skin');
                    }
                }
            } 
        }
    }
}
}).use('dd-drag', 'yui2-container', function (Y) {
        Y.one("#" + panelId).setStyle('display', null);
        var YAHOO = Y.YUI2;
        var config = {
            close: true,
            width: "300px",
            fixedcenter: true,
            modal: true
        };
        panel = new YAHOO.widget.Panel(panelId, config);
        var keylistener = new YAHOO.util.KeyListener(
    document, {
        keys: 27
    }, {
        fn: panel.hide,
        scope: panel,
        correctScope: true
    });
        panel.cfg.queueProperty("keylisteners", keylistener);
        panel.render();
    });
}

But this is not working. Throwing error: "YAHOO is undefined". Please help. Thanks..

A: 

Add an onFailure: function (error) {} method to your YUI3 config object. The error it gives you will tell you which files didn't load properly. I'm guessing the base property needs to be a full path not a relative path. I've never used patterns so I'm not sure how to debug it.

Killthesand