js-amd

require js remove definition to force reload

不打扰是莪最后的温柔 提交于 2019-12-03 08:34:07
For testing purposes I am trying to remove some amd modules and reload updated versions from the server - with the goal of not refreshing the browser. I am currently doing the following but the browser still doesn't reload the items from the network. var scripts = document.getElementsByTagName('script'); var context = require.s.contexts['_']; for (var key in context.defined) { if(key.indexOf("tests")>-1){ requirejs.undef(key); for (var i = scripts.length - 1; i >= 0; i--) { var script = scripts[i]; var attr = script.getAttribute('data-requiremodule') if (attr === key){ script.parentNode

Intermittent RequireJS Load Error

不羁岁月 提交于 2019-12-03 08:06:14
问题 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

Mocha + RequireJS = AMD testing

℡╲_俬逩灬. 提交于 2019-12-03 05:26:45
I have a hard time connecting Mocha to RequireJS based application, may be You'll be able to come up with something :). After many hours when I've been trying to load AMD modules and simply console.log some 'fired' info that the module has been loaded... nothing happend had happened - the program just ended and printed out some mocha info. var facade = requirejs(['../../public/js/scripts/widgets/widgets/article/main.js'], function(mod) { console.log('fired') }); // run with: $ mocha -u tdd test.js --reporter spec and than I've come up with the idea to fire just this to test callbacks:

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

耗尽温柔 提交于 2019-12-03 04:58:02
问题 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! 回答1: 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

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

有些话、适合烂在心里 提交于 2019-12-03 04:50:12
问题 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); };

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

时光怂恿深爱的人放手 提交于 2019-12-03 04:20:28
问题 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

RequireJS: Loading modules including templates and CSS [closed]

浪子不回头ぞ 提交于 2019-12-03 02:42:12
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . After playing around with AMD/RequireJS I was wondering if it is a good idea to load UI modules including templates and CSS so they are completely independent from the web page. It sounds like good, but I haven't seen this implemented in the wild so there may be pitfalls. Think of

Dojo require() and AMD (1.7)

允我心安 提交于 2019-12-03 02:07:15
I'm having a heckuva time transitioning to Dojo and the new AMD structure, and I'm really hoping someone can shed some light on the whole concept. I've been living on Google for the last few weeks trying to find information on not the usage, but the structure and design pattern trends in using this. I find it strange that for a relatively complex javascript application, such as for a main page where Dijits need to be created and styled, DOM elements created, etc, that I need to require, and therefore use, a TON of different modules that were otherwise available in the dojo namespace before the

Require js ruins code navigation

跟風遠走 提交于 2019-12-03 01:33:47
require.js states the way of defining objects inside modules with define([requiremens], object) as best way. So every page, or other js file, will do require() call and receive modules as parameters. This works pretty fine, each function/module has own namespace. The problem is that I have: // AJAX/Requests.js define(['UI/Message'],function(Message){ var Requests={ checkResponse:function(response){ //1==ok //0==error //2==good message //3==good message, but still stop if(response.status==1){ return true; } else if(response.status==2){ Message.good(response.message); return true; } else if

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

回眸只為那壹抹淺笑 提交于 2019-12-03 00:11:17
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . 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