requirejs

Run action after all requirejs modules are loaded

别说谁变了你拦得住时间么 提交于 2019-12-08 20:01:51
问题 There are several modules on page: // module 1 require(['signalr'], function(s) { s.subscribe('myhub1', function () { /* some code */ }); }); // module 2 require(['signalr'], function(s) { s.subscribe('myhub2', function () { /* some code 2 */ }); }); And there is method that should be invoked after all modules are invoked (all subscribtions are done): require(['signalr'], fuinction (s) { s.connect(); }); The possible solution is define modules and write like this: // module 1 define('module 1

Migrating Requirejs and Backbone based application to WebPack

别等时光非礼了梦想. 提交于 2019-12-08 19:35:34
I have a large application developed using Backbone.js and Marionette with Requirejs.We are using Grunt for build. I need to migrate Requirejs to Webpack as we are frequently seeing Module Load Timeout. I feel that multiple entry point approach of Webpack is a better approach than to convert single page to multi-page using Requirejs. Overall we have approximately 400 js file and 250 html[partial] files. The project structure is app |--modules | |-- module-A | |- model | |- collection | |- view | |- module_utils | |-- module-B | |---templates |-- module-A |- view-1.html |- view-2.html |--

Why is requirejs trying to load .map?

巧了我就是萌 提交于 2019-12-08 19:04:19
问题 I am trying to load scripts from a CDN (cdnjs to be specific), and in requirejs you have to leave the extension off like so: require.config({ baseUrl: '/static/js/', paths: { underscore: ['//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min'] }, shim: { 'underscore': { exports: '_' } } }); But when I do this, the browser tries to load underscore-min.map and not underscore-min.js . How do I fix this, and also what is a .map ? 回答1: .map files are needed for sourceMap support in

Howto bootstrap Backbone app with yeoman having require.js enabled

与世无争的帅哥 提交于 2019-12-08 17:40:02
问题 I'm playing with yeoman for a time now. I wonder how I accomplish bootstrapping a Backbone application and having require.js enabled at the same time. yeoman init provides me with a setup where I can work with modules in AMD style. yeoman init backbone:all provides me with a Backbone scaffold but I had to "include" all my models, collection etc. manually in index.html. Is there a way to have both? Regards Felix 回答1: There's already an open issue for this. Add your thoughts there :) 回答2: We

load javascript file before onload with requirejs

余生颓废 提交于 2019-12-08 17:39:32
I would like to use requireJS. However, I have a lib that needs to be loaded before the DOM. However, this is not what happens with requireJS <html> <head> <script data-main="/app" src="/require.js"></script> </head> <body> <bar-foo/> </body> </html> With app.js require.config({ paths: { 'customElement': '/customElement', 'barfoo': '/barfoo' }, shim: { barfoo: { deps: [ 'customElement' ] } } }); define(['barfoo'], function() { .... } For example, if I simply load this script directly in the head (without requireJS) it works fine. Is there a require-config-option so I can load a specific file

RequireJS - ASP.NET MVC Bundle Script

僤鯓⒐⒋嵵緔 提交于 2019-12-08 17:14:51
问题 I have two questions. I am trying to learn RequireJS and use it along with ASP.NET MVC bundling & minification. I am using a separate config file for RequireJS which holds the bundling information. My first problem is how do I pass on the bundle path generated by MVC to the require.config.js file. A clean way to do that will be as below: index.cshtml <script id="requirescript" type="text/javascript" src="~/Scripts/require.config.js" data-baseurl="@Url.Content("~/Scripts")" data-bundlepath="

How can google.maps.geometry be undefined?

柔情痞子 提交于 2019-12-08 16:42:06
问题 I'm writing a JavaScript application using the Google Maps Javascript API v3 and RequireJS. I wrote a little wrapper for gmaps in order to get the dependencies right: define('gmaps', ['goog!maps,3.9,packages:[geometry],language:de,other_params:sensor=false&channel=...&client=...'], function(){ return window.google.maps; }); This works perfectly fine in most of the cases, even after minifying the code using the optimizer. However, sometimes I get an error saying gmaps.geometry is undefined in

requirejs - not loading certainly with proper path given

主宰稳场 提交于 2019-12-08 14:28:06
问题 I am using 'requirejs' for my app development, it was worked properly but certainly it is not working now. all the path are correct. but i am getting error on load the page error i am getting: Remote Address:127.0.0.1:3000 Request URL:http://localhost:3000/js/lib/require.js //but exactly the file is here. Request Method:GET Status Code:404 Not Found here is my html for jade: doctype html html(lang='en') head title= name link(rel='stylesheet', href='styles/bootstrap.min.css') link(rel=

RequireJS how specify shim dependency from jam file package section

我是研究僧i 提交于 2019-12-08 13:26:42
问题 I'm working in a project with backbone-boilerplate which uses RequireJS to load modules and JamJS to manage them. My require config.js file is as follows: require.config({ deps: ["../vendor/jam/require.config", "main"], paths: { "backbone.localStorage": "../vendor/backbone.localStorage-1.0/backbone.localStorage" }, shim: { "backbone.localStorage": { deps: ['backbone'] } } }); As you can see the RequireJS load config from jam config file jam/require.config.js which specifies backbone, jquery

RequireJS + BackboneRelational + Self-Referential

十年热恋 提交于 2019-12-08 12:25:15
问题 I've been trying to follow the example here: Creating nested models with backboneJS + backbone-relational + requireJS And ended up having something different (since I need a Backbone.Collection, not a Backbone.RelationalModel): define(['exports', 'backbone', 'backbone.relational'], function (Exports, Backbone) { var ModuleModel = Backbone.RelationalModel.extend({ relations : [{ type : Backbone.HasMany, key : "children", relatedModel : 'ModuleModel', collectionType : 'ModuleCollection' }] });