2010-08-05 40 views
2

我是YUI的新手,我想在本地加载YUI 2,而不是从CDN加载。我已将两个和三个粘贴到同一个名为Scripts的目录中。我贴我的代码如下:YUI 2 in 3本地

<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(); 
    }); 
} 

但是,这是行不通的。投掷错误:“YAHOO未定义”。请帮忙。谢谢..

回答

0

添加onFailure:function(error){}方法到您的YUI3配置对象。它给你的错误会告诉你哪些文件没有正确加载。我猜基本属性需要是一个完整的路径而不是相对路径。我从来没有使用模式,所以我不知道如何调试它。