2012-05-31 15 views
8

http://requirejs.org/RequireJS eklentisi (order.js)

Geçenlerde 2.0 require.js indirilen ve benim konsolda hata alıyorum:

Uncaught TypeError: Object function(){var g=ga.call(arguments,0),e;if(f&&v(e=g[g.length-1]))e.__requireJsBuild=!0;g.push(d);return b.apply(null,g)} has no method 'nameToUrl' 

order.js Eklenti yine requirejs tarafından destekleniyor mu

? Belgelerini web sitesinde göremiyorum.

Dosyayı kaldırmaya çalıştığımda, komut dosyası kesiliyor. Benim main.js dosyasında Sonra

<!DOCTYPE html> 
<html> 
    <head> 
     <title> 
      My Mobile Application 
     </title> 
     <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" /> 
     <link rel="stylesheet" href="public/css/style.css" /> 
     <script data-main="scripts/main.js" src="scripts/require.js"></script> 
    </head> 
    <body></body> 
</html> 

: Benim dizin dosyasında

, ben head bölümünde requirejs senaryoyu dahil

requirejs.config({ 
    //By default load any module IDs from js/lib 
    baseUrl: 'js/lib', 
    //except, if the module ID starts with "app", 
    //load it from the js/app directory. paths 
    //config is relative to the baseUrl, and 
    //never includes a ".js" extension since 
    //the paths config could be for a directory. 
    paths: { 
     app: '../app', 
     assets: '../assets', 
     views: '../app/views', 
     templates: '../app/templates', 
     collections: '../app/collections', 
     models: '../app/models' 
    } 
}); 

// Start the main app logic. 
requirejs([ 
    'jquery/jquery', 
    'assets/jqm.config', 
    'jquery/mobile', 
    'text' 
]); 

require([ 
    'app' 
    ], 
    function(App){ 
     $(document).ready(function(){ 
      App.initialize(); 
     }); 
    } 
); 

Ben App.initialize kokan olduğunu görür Herhangi bir hata var ve App.initialize yapmak sadece basit coğrafi konumdur. Requirejs sadece order.js için talepte bulunur ve kodu koyduğumda yukarıda belirtildiği gibi aynı hatayı alır.

Teşekkür ederiz!

+3

[taşması bir zihin okuyucu değil] (http://meta.stackexchange.com/a/128551/177538). Kod nedir? – Joseph

+1

Bunun için üzgünüz. Düzenlenen. :) –

cevap

17

order'un artık desteklenmediği varsayımı doğrudur. Bu shim yapılandırma seçeneği lehine çıkarıldı:

So, the the order plugin has been removed and following the lead of Tim Branyen and Dave Geddes, of use and wrap respectively, requirejs 2.0 integrates that kind of dependency tree specification directly in requirejs.

2,0 yükseltme notları gerektir - http://requirejs.org/docs/api.html#config-shim

+0

Tamam, çok teşekkürler, bu gerçekten çok yardımcı oldu. Şimdi deneyecek ve çalışıp çalışmadığını bileceğim :) –

+0

Bu arada jQuery kullanıyorum ve daha önce indirdiğim [link] (http://requirejs.org/docs/download.html#samplejquery) verilen link, require.js yerine require-jquery.js'yi kullandım, şimdi bu hatayı alıyorum: plugin undefined. Çeşit hatalarını ayıklaması çok zor. –

+0

Krom denetleme öğesinde, bu hatayı alıyorum: Özellik undefined 'normalize' okunamıyor. Sigh * –

2

Ah bunu anladım - Ayrıca https://github.com/jrburke/requirejs/wiki/Upgrading-to-RequireJS-2.0

, RequireJS sitesinde shim belgelerine bakın.

//This is our main applicatoon boot loader or bootstrap 
//here we are loading necessary scripts dependencies like 
//jquery, jqm.config, mobile, text 


requirejs.config({ 
    baseUrl: 'js/libs', 
    //except, if the module ID starts with "app", 
    //load it from the js/app directory. paths 
    //config is relative to the baseUrl, and 
    //never includes a ".js" extension since 
    //the paths config could be for a directory. 
    paths: { 
     app: '../app', 
     assets: '../assets', 
     views: '../app/views', 
     templates: '../app/templates', 
     collections: '../app/collections', 
     models: '../app/models' 
    } 
}); 

// Start the main app logic. 

require(["jquery","assets/jqm.config","jquery/mobile","text","app"], 
    function(
    $, 
    config, 
    mobile, 
    text, 
    App 
    ) { 
    //the jquery.alpha.js and jquery.beta.js plugins have been loaded. 
    $(function() { 
     App.initialize(); 
    }); 
}); 
İlgili konular