js-amd

Loading Highcharts via shim using RequireJS and maintaining jQuery dependency

∥☆過路亽.° 提交于 2019-11-28 21:17:11
问题 I'm attempting to load the Highcharts library using a shim in RequireJS. However, when Highcharts loads, it throws an exception because it can't access the jQuery methods it depends on. The require config looks like so: require.config({ baseUrl: "js", shim: { 'libs/highcharts/highcharts.src.js': { deps: ['jquery'], exports: function(jQuery) { this.HighchartsAdapter = jQuery; return this.Highcharts; } } } }); The exception that is thrown is: Uncaught TypeError: undefined is not a function and

How to load Google Maps API with RequireJS?

五迷三道 提交于 2019-11-28 16:11:49
I am struggling to load gmaps api with requireJS . This is what I've tried: requirejs.config({ urlArgs: "noCache=" + (new Date).getTime(), paths : { "jquery": "vendor/jquery-1.8.2.min", "bootstrap": "vendor/bootstrap.min", "underscore": "libs/underscore-min", "backbone": "libs/backbone-min", "template": "libs/template", "gmaps": "http://maps.google.com/maps/api/js?v=3&sensor=false" }, shim: { 'backbone': { deps: ['jquery', 'underscore'], exports: 'Backbone' }, 'underscore': { exports: '_' }, 'bootstrap': { deps: ['jquery'] }, 'gmaps': { deps: ['jquery'] }, 'main':{ deps: ['jquery','gmaps'] } }

Why did Underscore.js remove support for AMD?

对着背影说爱祢 提交于 2019-11-28 04:27:26
1.3.0 — Jan. 11, 2012 Removed AMD (RequireJS) support from Underscore. If you'd like to use Underscore with RequireJS, you can load it as a normal script, wrap or patch your copy, or download a forked version. Why have they done it? Does anyone know? Because they added it only few month ago (in October), and AMD (Asynchronous Module Definition) is said to be far superior to CommonJS modules. Update: As of December 2013, this has been supported again. Jeremy gave his reasoning in the comments of the commit : Yep. Not supporting a particular script loader will definitely make it easier for all

Polymer + requirejs: Attributes on were data bound prior to Polymer upgrading the element

北城余情 提交于 2019-11-28 02:07:27
问题 I'm trying to use requirejs with Polymer: <polymer-element name="test-element"> <script> require(['module'], function (module) { Polymer('test-element', module); }); </script> <template> Test </template> </polymer-element> But I get the warning: Attributes on test-element were data bound prior to Polymer upgrading the element. This may result in incorrect binding types. Should I be concerned about this warning? What can I do to make attributes be data bound after Polymer upgrades the element?

require.js: Access all loaded modules

霸气de小男生 提交于 2019-11-27 17:58:37
Is there any way to access all loaded modules of require.js? Background: I want to automatically call an init() function of my javascript-modules after all of them are loaded, see require.js + backbone.js: How to structure modules that have an initialize function? Without require.js I looped over my own module-storage and called each init() function. I now want to do this with require.js. I'm aware that calling a my_custom_init_function_favoritecolor_petname_love123 of every loaded module (including external libraries) is dangerous. I hope that this will cause less trouble than manually

How to achieve lazy loading with RequireJS?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 17:14:39
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 initialized; each top-level router has a set of dependencies (models, views, etc) which each have their

Why did Underscore.js remove support for AMD?

三世轮回 提交于 2019-11-27 05:23:13
问题 1.3.0 — Jan. 11, 2012 Removed AMD (RequireJS) support from Underscore. If you'd like to use Underscore with RequireJS, you can load it as a normal script, wrap or patch your copy, or download a forked version. Why have they done it? Does anyone know? Because they added it only few month ago (in October), and AMD (Asynchronous Module Definition) is said to be far superior to CommonJS modules. Update: As of December 2013, this has been supported again. 回答1: Jeremy gave his reasoning in the

require.js: Access all loaded modules

房东的猫 提交于 2019-11-26 22:36:30
问题 Is there any way to access all loaded modules of require.js? Background: I want to automatically call an init() function of my javascript-modules after all of them are loaded, see require.js + backbone.js: How to structure modules that have an initialize function? Without require.js I looped over my own module-storage and called each init() function. I now want to do this with require.js. I'm aware that calling a my_custom_init_function_favoritecolor_petname_love123 of every loaded module

How to load bootstrapped models in Backbone.js while using AMD (require.js)

青春壹個敷衍的年華 提交于 2019-11-26 18:06:28
Backbone.js documentation suggest loading bootstrapped models this way: <script> var Accounts = new Backbone.Collection; Accounts.reset(<%= @accounts.to_json %>); var Projects = new Backbone.Collection; Projects.reset(<%= @projects.to_json(:collaborators => true) %>); </script> But this is a pattern that can't be used in AMD approach (using require.js) The only possible solution is to declare global variable storing JSON data and use this variable later in relevant initialize methods. Is there a better way to do this (without globals)? This is how we bootstrap data in a way that it doesn't

How to load bootstrapped models in Backbone.js while using AMD (require.js)

 ̄綄美尐妖づ 提交于 2019-11-26 06:13:00
问题 Backbone.js documentation suggest loading bootstrapped models this way: <script> var Accounts = new Backbone.Collection; Accounts.reset(<%= @accounts.to_json %>); var Projects = new Backbone.Collection; Projects.reset(<%= @projects.to_json(:collaborators => true) %>); </script> But this is a pattern that can\'t be used in AMD approach (using require.js) The only possible solution is to declare global variable storing JSON data and use this variable later in relevant initialize methods. Is