2012-05-31 4 views
8

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

I require.js 2.0 vor kurzem heruntergeladen und ich erhalte Fehler in meiner Konsole:

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' 

Ist order.js Plugin noch von requirejs unterstützt? Ich sehe seine Dokumentation nicht auf der Website.

Wenn ich versuche, die Datei zu entfernen, bricht das Skript ab.

In meiner Index-Datei, ich requirejs Skript im Kopfteil enthalten:

<!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> 

Dann in meiner main.js Datei:

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

ich sorgt dafür, dass App.initialize doesn‘ t haben irgendwelche Fehler und was App.initialize macht, ist nur eine einfache geo location. Die Requirejs fragen einfach nach order.js, und wenn ich den Code einfüge, hat er den gleichen Fehler wie oben erwähnt.

Vielen Dank!

+3

[Stapelüberlauf ist kein Mind Reader] (http://meta.stackexchange.com/a/128551/177538). Was ist der Code? – Joseph

+1

Entschuldigung. Bearbeitet. :) –

Antwort

17

Ihre Annahme, dass order nicht mehr unterstützt wird, ist korrekt. Es wurde zugunsten der Option shim Konfiguration entfernt:

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.

erforderlich 2.0 Upgrade-Hinweise - https://github.com/jrburke/requirejs/wiki/Upgrading-to-RequireJS-2.0

Überprüfen Sie auch die shim Dokumentation auf der RequireJS Website - http://requirejs.org/docs/api.html#config-shim

+0

Ok vielen Dank, das war wirklich eine große Hilfe. Versuche es jetzt und lasse Sie wissen, ob es funktioniert :) –

+0

Ich benutze jQuery übrigens und früher habe ich [link] (http://requirejs.org/docs/download.html#samplejquery) eine Datei von der heruntergeladen gegebener link, ich habe es benötigt request-jquery.js anstelle von require.js, jetzt bekomme ich diesen Fehler: plugin ist undefined. Es ist sehr schwierig, die Artenfehler zu debuggen. –

+0

Im incheck-Element von chrome erhalte ich diesen Fehler: Die Eigenschaft 'normalize' von undefined kann nicht gelesen werden. Seufz * –

2

Oh es herausgefunden.

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