2010-08-05 22 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配置對象。它給你的錯誤會告訴你哪些文件沒有正確加載。我猜基本屬性需要是一個完整的路徑而不是相對路徑。我從來沒有使用模式,所以我不知道如何調試它。