js-amd

Asynchronous load of TypeScript declarations with no exports

妖精的绣舞 提交于 2019-12-07 03:32:08
问题 I have a number of jQuery plugins that I would like to load using the AMD pattern in TypeScript. For example, I might have this structure: /lib/jquery.myplugin.js /app.ts The plugin simply extends jQuery. It provides no new top-level functions or variables. An example might be: // jquery.myplugin.js jQuery.fn.myExample = function() { ... } The corresponding jquery.myplugin.d.ts file looks like: interface JQuery { myExample(); } So that now in app.ts I can call something like $('#my-element')

How do I use uncompressed files in Dojo 1.7?

可紊 提交于 2019-12-06 01:20:17
I've created a Dojo module which depends on dojox/data/JsonRestStore like this: define("my/MyRestStore", ["dojo/_base/declare", "dojox/data/JsonRestStore"], function(declare, JsonRestStore) { var x = new JsonRestStore({ target: '/items', identifier: 'id' }); ... which is fine. But now I want to have the the uncompressed version of the JsonRestStore code loaded so that I can debug it. I can't find any documentation on how to do this, but since there is a file called 'JsonRestStore.js.uncompressed.js' I changed my code to: define("my/MyRestStore", ["dojo/_base/declare", "dojox/data/JsonRestStore

RequireJS: module ID vs module name

扶醉桌前 提交于 2019-12-05 04:32:22
问题 I'm kinda noob in RequireJS; I recently read the API documentation, and came across these two terms: module ID and module name . Are they used interchangeably? Or are they somehow different concepts? Excerpts: http://requirejs.org/docs/api.html#jsfiles RequireJS also assumes by default that all dependencies are scripts, so it does not expect to see a trailing ".js" suffix on module ID s. RequireJS will automatically add it when translating the module ID to a path. http://requirejs.org/docs

Backbone Marionette: Marionette.Application causing Require.js module load error, “'Error: Module name 'App' has not been loaded yet for context: _”

落爺英雄遲暮 提交于 2019-12-04 21:09:49
I'm trying to include the App instance to use it's event aggregator as shown here I get an error when I include the instance in a view. Kicking things off in the Requirejs config file, from App.Bootloader.js: require(['App'], function (App){ App.start(); }); from App.js: define(function (require){ //...requisite includes $, _, Backbone, Marionette ... var Layout = require('Layout'); var App = new Marionette.Application(); App.addRegions({ main: '#view_content' }); App.addInitializer(function (){ App.main.show(new Layout()); //... adding router etc ... Backbone.Marionette.TemplateCache

How does AMD (specifically RequireJs) handle dependancies across multiple modules

梦想与她 提交于 2019-12-04 03:39:54
I have my main initialization script which calls require() and one of the dependencies is a utilities framework, but some of the other modules that I'm specifying via require() also themselves have defined this framework as a dependency. For example (init.js): require(['module-a', 'module-b', 'module-c'], function(a, b, c){ // where module-c is the framework }); And then in 'module-a' I have: define(['module-c'], function(c){ // utilize module-c framework }); So how does AMD/RequireJs handle this scenario, does it load the same framework twice? Any help appreciated. Kind regards, Mark It will

require.js + backbone.js: How to structure modules that have an initialize function?

你。 提交于 2019-12-03 16:48:20
I have an application with three pages (which are single-page interfaces). The pages have similar but not identical functionality. So I want to have javascript-modules that provide the common functionality. Then each page may customize/overwrite parts of the common functionality. I'm using backbone.js, so what I do is: load the files containing the common Models, Views, Collections etc. load app-specific files that customize/overwrite parts of step 1 call an init() function that instanciates all necessary Models/Views/Collections At the moment I store my modules in a module-container similar

Mocha + RequireJS = AMD testing

谁说我不能喝 提交于 2019-12-03 16:14:38
问题 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

How to write a module that works with Node.js, RequireJS as well as without them

给你一囗甜甜゛ 提交于 2019-12-03 13:41:40
I am working on a JavaScript library for JSON/XML processing . My library works in browser as well as Node.js (with xmldom and xmlhttprequest modules). One of the users recently asked for RequireJS support. I have taken a look at the RequireJS/AMD thing and think it is a good approach so I'd like to provide this. However I'd like to retain the portability: my library must work in browsers (with and without RequireJS) as well as Node.js. And in the browser environment I don't depend on xmldom or xmlhttprequest since these things are provided by the browser itself. My question is: how can I

Require js ruins code navigation

风格不统一 提交于 2019-12-03 11:09:12
问题 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){

Dojo require() and AMD (1.7)

ぐ巨炮叔叔 提交于 2019-12-03 10:34:38
问题 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