最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - RequireJS plugin( order.js ) - Stack Overflow

programmeradmin1浏览0评论

/

I recently downloaded require.js 2.0 and I am getting error in my console:

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'

Is order.js plugin still supported by requirejs? I don't see its documentation in the website.

When I try to remove the file the script breaks.

In my index file, I included requirejs script in the head section:

<!DOCTYPE html>
<html>
    <head>
        <title>
            My Mobile Application
        </title>
        <link rel="stylesheet" href=".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>

Then in my main.js file:

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

I sees to it that App.initialize doesn't have any errors and what App.initialize is doing is just simple geo location. The requirejs simply ask for order.js, and when I put the code it's having the same error as mentioned above.

Thank you!

http://requirejs.org/

I recently downloaded require.js 2.0 and I am getting error in my console:

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'

Is order.js plugin still supported by requirejs? I don't see its documentation in the website.

When I try to remove the file the script breaks.

In my index file, I included requirejs script in the head section:

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

Then in my main.js file:

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

I sees to it that App.initialize doesn't have any errors and what App.initialize is doing is just simple geo location. The requirejs simply ask for order.js, and when I put the code it's having the same error as mentioned above.

Thank you!

Share Improve this question edited May 31, 2012 at 21:56 Joseph Ledesma Gabito asked May 31, 2012 at 21:26 Joseph Ledesma GabitoJoseph Ledesma Gabito 3611 gold badge4 silver badges10 bronze badges 1
  • 3 Stack Overflow is not a Mind Reader. What's the code? – Joseph Commented May 31, 2012 at 21:31
Add a comment  | 

2 Answers 2

Reset to default 17

Your assumption that order is no longer supported is correct. It was removed in favour of the shim configuration option:

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.

Require 2.0 upgrade notes - https://github.com/jrburke/requirejs/wiki/Upgrading-to-RequireJS-2.0

Also, check the shim documentation on the RequireJS site - http://requirejs.org/docs/api.html#config-shim

Oh figured it out.

//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();
    });
});
发布评论

评论列表(0)

  1. 暂无评论