requirejs

Require.js Error: Load timeout for modules: backbone,jquerymobile

血红的双手。 提交于 2019-12-17 15:11:23
问题 I am trying to use r.js to optimize my code but I keep running to this error: Tracing dependencies for: init Error: Load timeout for modules: backbone,jquerymobile The command I am running is this: $ java -classpath /Users/dixond/build-tools/rhino1_7R4/js.jar:/Users/dixond/build-tools/closurecompiler/compiler.jar org.mozilla.javascript.tools.shell.Main /Users/dixond/build-tools/r.js/dist/r.js -o /Users/dixond/Sites/omm_mobile/js/build.js My build.js file looks like this: ( { //appDir: "some

What is 'define' used for in JavaScript (aside from the obvious)?

只愿长相守 提交于 2019-12-17 10:07:55
问题 I have searched high and low for documentation on this, but I just cannot find anything anywhere. I am using Aloha and want to use their sidebar prototype to create a new side bar of my own attached to other plugin functionality. Their sidebar.js starts off with this, but I can't for the life of me find any documentation that explains what it means. define( [ 'aloha/core', 'aloha/jquery', 'aloha/selection' ], function (Aloha, jQuery, Selection, Plugin) { It then goes on in that wrapper to

How do I use requireJS and jQuery together?

与世无争的帅哥 提交于 2019-12-17 07:58:04
问题 I would like to use requireJS and I am using jQuery. I don't want to use the combined version of requireJS and jQuery since I am not using the latest jQuery version. What is the best way for me to work with requireJS? 回答1: That is my exact question too! I also must use an older jQuery, but also more "traditional" javascript libraries. What is the best technique to do that? (I may edit your question to make it more broad if you don't mind.) Here is what I learned. RequireJS author, James Burke

Using RequireJS, how do I pass in global objects or singletons around?

五迷三道 提交于 2019-12-17 07:02:45
问题 Let's say I am writing code at the main page level and 2 dependencies require the same instance of an object and also state that as a dependency. What is the appropriate way to go about this? Basically what I want to do is say, "If this dependency isn't loaded... then load it. Otherwise, use the same instance that was already loaded and just pass that one." 回答1: You would make that a module-level variable. For example, // In foo.js define(function () { var theFoo = {}; return { getTheFoo:

RequireJS - is jQuery case sensitive?

怎甘沉沦 提交于 2019-12-17 05:14:16
问题 I am attempting to get started with RequireJS, and am running into an annoying issue. . . require.config({ baseUrl: 'app_content/scripts', paths: { // the left side is the module ID, // the right side is the path to // the jQuery file, relative to baseUrl. // Also, the path should NOT include // the '.js' file extension. This example // is using jQuery 1.9.0 located at // js/lib/jquery-1.9.0.js, relative to // the HTML page. 'jQuery': 'lib/jQuery/jQuery-2.0.3' } }); This, using uppercase Q ,

angular-ui-router with requirejs, lazy loading of controller

怎甘沉沦 提交于 2019-12-17 03:39:33
问题 Could you help me to understand how to load controller in the example below before the view? It looks like the view is loaded just immediately while the controller is not loaded yet. //app.js $stateProvider.state('index', { url: "/", views: { "topMenu": { templateUrl: "/Home/TopMenu", controller: function($scope, $injector) { require(['controllers/top-menu-controller'], function(module) { $injector.invoke(module, this, { '$scope': $scope }); }); } } } }); //top-menu-controller.js define(['app

angular-ui-router with requirejs, lazy loading of controller

ぐ巨炮叔叔 提交于 2019-12-17 03:38:33
问题 Could you help me to understand how to load controller in the example below before the view? It looks like the view is loaded just immediately while the controller is not loaded yet. //app.js $stateProvider.state('index', { url: "/", views: { "topMenu": { templateUrl: "/Home/TopMenu", controller: function($scope, $injector) { require(['controllers/top-menu-controller'], function(module) { $injector.invoke(module, this, { '$scope': $scope }); }); } } } }); //top-menu-controller.js define(['app

Why use Object.prototype.hasOwnProperty.call(myObj, prop) instead of myObj.hasOwnProperty(prop)?

那年仲夏 提交于 2019-12-17 02:41:13
问题 If I understand correctly, each and every object in Javascript inherits from the Object prototype, which means that each and every object in Javascript has access to the hasOwnProperty function through its prototype chain. While reading require.js' source code, I stumbled upon this function: function hasProp(obj, prop) { return hasOwn.call(obj, prop); } hasOwn is a reference to Object.prototype.hasOwnProperty . Is there any practical difference to writing this function as function hasProp(obj

requirejs, almond: A stand alone module built with almond loads all dependencies, but the main code is not executed

怎甘沉沦 提交于 2019-12-14 04:01:55
问题 I am trying to build a stand alone module with almond and this is my setup. The question is at the bottom. Abbreviated directory structure is: |-static |-core |-js |-require.js |-almond.js |-common.js |-app.build.js |-app |-myApp.js |-vendor |-js |-jquery.js |-bootstrap.js |-fancybox.js Abbreviated contents of common.js: require.config({ baseUrl: "/static/core/js", paths: { 'jquery':'../../vendor/jquery/1.7.2/jquery', 'bootstrap':'../../vendor/bootstrap/2.2.2/js/bootstrap', 'fancybox':'../..

How can I provide a pseudo file system for r.js?

一个人想着一个人 提交于 2019-12-14 04:00:01
问题 Ok, so r.js can run on Rhino. Which is great. To do the stuff it needs to do. On rhino it basically uses java.io.File , java.io.FileOutputStream and java.io.FileInputStream to achieve the filesystem modifications that it needs to do. (Background: I am working on delivering a better development experience for Maven based Java/Javascript developers. Being Maven, there is the power of convention and the power of being opinionated. You can see the progress at jszip.org.) So what I want to do is