requirejs

Using the Backbone.js router to navigate through views modularized with require.js

二次信任 提交于 2019-12-18 10:01:49
问题 I am separating my views and router into separate files with require. I then have a main.js file that instantiates the router, and also renders my default view. My router has view ('View/:id') and edit ('Edit/:id') as routes. In main.js, when I instantiate the router, I can hardcode router.navigate('View/1', true) and the navigation works fine. In my view file, when I click on the edit link, I want to call router.navigate('View/' + id, true), but I'm not sure how I should do this. I've had

Using reactjs with requirejs

旧城冷巷雨未停 提交于 2019-12-18 09:54:34
问题 Recently, I started using reactjs along with a backbonejs router to build an application. I usually use use requirejs for dependency and code management. But, problem arises when I try to include files that contain jsx syntax. This is what I have so far as my router.js : define(["backbone", "react"], function(Backbone, React) { var IndexComponent = React.createClass({ render : function() { return ( <div> Some Stuff goes here </div> ); } }); return Backbone.Router.extend({ routes : { "":

Trouble combining Require.js and Backbone.js/Underscore.js

♀尐吖头ヾ 提交于 2019-12-18 09:23:29
问题 I've read previous threads where other members have had identical error messages as me, but their accepted solution doesn't seem to help. Basically I get this in Chrome console when I try to load index.html: Uncaught Error: Module name "underscore" has not been loaded yet for context: _. Use require([]) A couple of seconds later this shows up: Uncaught Error: Load timeout for modules: underscore,backbone Chrome network tools doesn't show any anomalies everything up until day_view.js is loaded

How do I document AMD + Backbone project with JSDoc3

情到浓时终转凉″ 提交于 2019-12-18 05:56:29
问题 I have a Backbone boilerplate based project, that I want to document with recent jdoc-toolkit Though I can't get it to generate anything but empty _global class Code sample: /** * This is a root model for DLClass * @module models/DLClass */ define([ 'underscore', 'backbone' ], /** @lends DLClass */ function (_, Backbone) { /** * This is a root model for DLClass * @class DLClass * @constructor * @return Session Object */ var DLModel = Backbone.Model.extend({ /** @lends DLClass.prototype */ /**

RequireJS + Backbone + jQuery loaded through `script` interfering with jQuery loaded through RequireJS

浪尽此生 提交于 2019-12-18 05:25:09
问题 I just tried upgrading to Backbone 1.1.2, and have been having issues with jQuery. By default, Backbone expects to find the jQuery in the base directory as ./jquery.js . When I add this into the RequireJS path and add it to the shim as a dependency for Backbone, then everything works inside of require , but outside, nothing works. It's as if the local reference I am creating is stomping over the globally included jQuery? In my html page, I have this: <script src="js/lib/jquery/2.0.2/jquery

solving circular dependency in node using requirejs

送分小仙女□ 提交于 2019-12-18 05:15:10
问题 I have been try out many suggestions I found googling for circular dependency in node and requirejs. Unfortunately, I'm not getting it to work. The try which is closed to a solution (I think) is below: // run.js var requirejs = require('requirejs'); requirejs.config({ baseUrl: __dirname, nodeRequire: require }); requirejs(['A'], function(A) { var a = new A.Go(); console.log(a.toon()) }); // A.js define(['B', 'exports'], function(B, exports) { exports.Go = function() { var b = new require('B')

global variables in requireJS [duplicate]

亡梦爱人 提交于 2019-12-18 04:42:10
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to load bootstrapped models in Backbone.js while using AMD (require.js) This is a simple demo about my problem. I need to access the id_user in main.js file. My question is, how to avoid global variables in this situation? It is bad practice use global variables for this purpose? main.js require({ paths : { jQuery : 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min' } }); require([ 'jQuery' ],

Requirejs: paths vs map

a 夏天 提交于 2019-12-18 04:29:15
问题 Trying to understand where it's right to use "map" with a wildcard vs "paths". Looking at the require source (but certainly not being 100% fluent with it) it seems like there would functionally be no difference between these two snippets. Is that true? Using Paths: require.config({ baseUrl: "include/js/", paths: { foo: "stuff/foo", } }); Using Map: require.config({ baseUrl: "include/js/", map: { '*': {foo: "stuff/foo"}, } }); 回答1: From the RequireJS Docs "In addition, the paths config is only

How do you setup a require.js config with typescript?

泪湿孤枕 提交于 2019-12-18 03:51:18
问题 Ok, I've been reading a lot of questions and answers about this, and a lot of it is rubbish. I have a very simple question. How do I do the equivalent of this: require.config({ paths: { "blah": '/libs/blah/blah', } }); require(['blah'], function(b) { console.log(b); }); In typescript? This doesn't work: declare var require; require.config({ paths: { "blah": '/libs/blah/blah', } }); import b = require('blah'); console.log(b); s.ts(8,1): error TS2071: Unable to resolve external module ''blah''.

How do you setup a require.js config with typescript?

放肆的年华 提交于 2019-12-18 03:51:04
问题 Ok, I've been reading a lot of questions and answers about this, and a lot of it is rubbish. I have a very simple question. How do I do the equivalent of this: require.config({ paths: { "blah": '/libs/blah/blah', } }); require(['blah'], function(b) { console.log(b); }); In typescript? This doesn't work: declare var require; require.config({ paths: { "blah": '/libs/blah/blah', } }); import b = require('blah'); console.log(b); s.ts(8,1): error TS2071: Unable to resolve external module ''blah''.