requirejs

Lazy load template and controller in angular UI-Router

左心房为你撑大大i 提交于 2019-12-17 18:52:52
问题 I am attempting to lazy load a controller and template in my UI-Router router.js file, but am having difficulty with the template. The controller loads properly, but after that is loaded, we must load the template and this is where things go wrong. After ocLazyLoad loads the controller, we resolve an Angular promise which is also included in the templateProvider. The issue is instead of returning the promise (templateDeferred.promise) after the file is done loading, the promise is returned as

How can I include jQueryUI in my modular backbone.js app using RequireJS?

核能气质少年 提交于 2019-12-17 18:52:47
问题 I want to include jQueryUI in my backbone.js app using RequireJS. The main.js file included in my index.html is as follows: require.config({ paths: { jquery: 'libs/jquery/jquery-1.7.2.min', jqueryui: 'libs/jquery/jquery-ui-1.8.18.custom.min', underscore: 'libs/underscore/underscore-min', backbone: 'libs/backbone/backbone-optamd3-min', text: 'libs/require/text', templates: 'templates' } }); require(['app'], function(App){ App.start(); }); And for each model/view/router file, I just include the

jQuery source code uses Require.js, but the final file doesn't?

别来无恙 提交于 2019-12-17 18:42:11
问题 Uncompressed jQuery file: http://code.jquery.com/jquery-2.0.3.js jQuery Source code: https://github.com/jquery/jquery/blob/master/src/core.js What are they doing to make it seem like the final output is not using Require.js under the hood? Require.js examples tells you to insert the entire library into your code to make it work standalone as a single file. Almond.js, a smaller version of Require.js also tell you to insert itself into your code to have a standalone javascript file. When

karma error 'There is no timestamp for'

天大地大妈咪最大 提交于 2019-12-17 17:59:43
问题 Trying to get karma working with requirejs. I don't understand why I am getting all of these errors when running Karma: ERROR: 'There is no timestamp for /base/test/mainSpec.js?bust=1387739317116!' ERROR: 'There is no timestamp for /base/app/main.js?bust=1387739317116!' ERROR: 'There is no timestamp for /base/bower_components/jquery/jquery.js?bust=1387739317116!' When I go to the network tab in inspector, all of the files are there with no 404s. I'm a little confused because karma seems to be

RequireJS: To Bundle or Not to Bundle

老子叫甜甜 提交于 2019-12-17 17:58:11
问题 I'm using RequireJS for my web application. I'm using EmberJS for the application framework. I've come to a point where, I think, I should start bundling my application into a single js file. That is where I get a little confused: If I finally bundle everything into one file for deployment, then my whole application loads in one shot, instead of on demand. Isn't bundling contradictory to AMD in general and RequireJS in particular? What further confuses me, is what I found on the RequireJS

RequireJS Compilation in Maven project with external JS dependencies

て烟熏妆下的殇ゞ 提交于 2019-12-17 17:34:37
问题 I have a web project that's built with Maven and I'm trying to figure out the best way to compile the JavaScript files with the RequireJS compiler (this question could apply to any compiler/minifier as well). I have a setup that works, but it needs improvement: I've packaged the 3rd party JavaScript libraries and they are being downloaded as dependencies and then added with the WAR Overlay plugin. I have an Exec plugin task that runs the RequireJS compiler inside the target directory. I

Preload script without execute

自作多情 提交于 2019-12-17 16:45:07
问题 Problem In order to improve the page performance I need to preload scripts that I will need to run on the bottom page . I would like to take control of when the script is parsed, compiled and executed. I must avoid the script tag , because it is blocker for common render engines (geeko, etc). I can't load it using defer property, because I need to control when the script is executed. Also, async property is not a possibility. sample: <html><head> //preload scripts ie: a.js without use the

Dependency Injection with RequireJS

风流意气都作罢 提交于 2019-12-17 15:16:49
问题 How much can I stretch RequireJS to provide dependency injection for my app? As an example, let's say I have a model that I want to be a singleton. Not a singleton in a self-enforcing getInstance()-type singleton, but a context-enforced singleton (one instance per "context"). I'd like to do something like... require(['mymodel'], function(mymodel) { ... } And have mymodel be an instance of the MyModel class. If I were to do this in multiple modules, I would want mymodel to be the same, shared

Shim Twitter Bootstrap for RequireJS

做~自己de王妃 提交于 2019-12-17 15:16:44
问题 The RequireJS docs say that to support older versions of IE, you need to configure enforceDefine: true . So if you want to support Internet Explorer, catch load errors, and have modular code either through direct define() calls or shim config, always set enforceDefine to be true. See the next section for an example. NOTE: If you do set enforceDefine: true, and you use data-main="" to load your main JS module, then that main JS module must call define() instead of require() to load the code it

How to achieve lazy loading with RequireJS?

十年热恋 提交于 2019-12-17 15:13:16
问题 We're building a non-trival web application using Backbone, RequireJS and Handlebars, and well, I'm just curious. At the moment, each of our models sorta looks like this: define(['Backbone', 'js/thing/a', 'js/thing/b', 'js/lib/bob'], function(a, b, bob) { return Backbone.Router.extend({ // stuff here }); }); where thing/a, thing/b both have their own dependencies, for example on Handlebars templates, etc. What happens now is that in my main.js, all of the 'top-level' routers are loaded and