js-amd

Intermittent RequireJS Load Error

╄→гoц情女王★ 提交于 2019-12-02 20:45:25
I have a rather large Backbone.js project that uses RequireJS. As the project size grew ("size" here referring to the number of separate module files), intermittent errors started cropping up. Most of the time, it's an object error: Uncaught TypeError: object is not a function Occasionally, it complains about a module not being loaded. These errors disappear once the project is run through the r.js optimizer. They only happen when RequireJS is loading the individual modules. Which brings me down to my question - does RequireJS start having issues with modules loading in time when the number of

With AMD modules, when (or why) is it OK to use require() within define()?

六月ゝ 毕业季﹏ 提交于 2019-12-02 18:40:20
My understanding of AMD modules (using for example RequireJs or curl.js) is: require() is used to asynchronously load different modules and when loaded then the callback fn is executed. And to define a module, you would have separate scripts that use define() But I've seen some modules use require() inside their function definition, e.g. define([a, b, c], function(i, ii, iii){ require([d, e, f], function(d, e, f) { // do some stuff with these require()'d dependancies }) /* rest of the code for this module */ }) But I find this confusing because I would have thought that if a module has

How to document a Require.js (AMD) Modul with jsdoc 3 or jsdoc?

随声附和 提交于 2019-12-02 18:02:03
I have 2 types of Modules: Require.js Main File : require.config({ baseUrl: "/another/path", paths: { "some": "some/v1.0" }, waitSeconds: 15, locale: "fr-fr" }); require( ["some/module", "my/module", "a.js", "b.js"], function(someModule, myModule) { } ); Mediator Pattern: define([], function(Mediator){ var channels = {}; if (!Mediator) Mediator = {}; Mediator.subscribe = function (channel, subscription) { if (!channels[channel]) channels[channel] = []; channels[channel].push(subscription); }; Mediator.publish = function (channel) { if (!channels[channel]) return; var args = [].slice.call

What is the main difference between require() and define() function in dojo and when would we use either?

泄露秘密 提交于 2019-12-02 17:27:27
I am new to learning dojo and I have come across the require() and define() functions and I can not get my head around either of them. Also, when would I use either of them? A small demo or example would be beneficial. Many Thanks! require and define are part of the asynchronous module definition (AMD) API. You use define to define a module that can be consumed by other code. Generally, define will be used in a javascript file. The javascript file is defining a module. All Dojo files use define. You use require when you are not defining a module, but you require modules that have been defined.

What's the difference between Require.js and simply creating a <script> element in the DOM? [closed]

↘锁芯ラ 提交于 2019-12-02 13:56:25
What's the difference between using Require.JS amd simply creating a <script> element in the DOM? My understanding of Require.JS is that it offers the ability to load dependencies, but can this not simply be done by creating a <script> element that loads the necessary external JS file? For example, lets assume I have the function doStuff() , which requires the function needMe() . doStuff() is in the external file do_stuff.js , while needMe() is in the external file need_me.js . Doing this the Require.JS way: define(['need_me'],function(){ function doStuff(){ //do some stuff needMe(); //do some

Load Locale File Dynamically using Requirejs

孤人 提交于 2019-12-01 18:59:24
I have a single page Marionette app built on RequireJS which needs to support translations. My goal is to have a dictionary file for each language, and based on the logged in user's configuration, load the relevant file. Since most of the users will use English, I want to bundle the English dictionary in the app during build (using r.js). I wrote a small Translator module, which basically wraps jed.js (the library I'm using for i18n): //in myTranslator.js define(function (require) { "use strict"; var Jed = require("jed"); var localeData = require("json!locales/en_US.json"); var Translator =

Load Locale File Dynamically using Requirejs

戏子无情 提交于 2019-12-01 18:50:52
问题 I have a single page Marionette app built on RequireJS which needs to support translations. My goal is to have a dictionary file for each language, and based on the logged in user's configuration, load the relevant file. Since most of the users will use English, I want to bundle the English dictionary in the app during build (using r.js). I wrote a small Translator module, which basically wraps jed.js (the library I'm using for i18n): //in myTranslator.js define(function (require) { "use

Loading Highcharts via shim using RequireJS and maintaining jQuery dependency

谁都会走 提交于 2019-11-30 00:15:57
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 is in regards to this line: dataLabels: merge(defaultLabelOptions, { The issue is the merge call, which

Javascript AMD Modules: How to get Visual Studio intellisense across modules

别等时光非礼了梦想. 提交于 2019-11-29 19:52:03
问题 After looking into Asynchronous Module Definition (AMD) in the javascript context I was wondering how to get intellisense in Visual Studio 2010 for a dependent module. For example given module A: define(function() { return { square: function(value) { return value * value; } }; }); and a corresponding module B: define(["A"], function(a) { return { value: a.square(10) } }); Then I would like to have full intellisense for the module A (represented as parameter a) within module B. Note that both

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

杀马特。学长 韩版系。学妹 提交于 2019-11-29 08:46:19
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? Is there any other Polymer specific loader to load AMD modules into polymer web components? --------