requirejs

Using config in a RequireJS plugin

邮差的信 提交于 2020-01-15 03:37:37
问题 I'm trying to write a RequireJS plugin that takes in the name of the module requested, dynamically figures out its path, then loads it. The logic to determine these paths is based on some specific business logic, so it's unlikely any existing plugins that do similar things will be useful to me. I initially tried to use the plugin's normalize method, but weird things were happening: normalize was being called twice, after which the load method was called with an empty string for the name. I

Chutzpah and Jasmine 2.0 and RequrieJs

半腔热情 提交于 2020-01-14 10:08:34
问题 I'm having some bother getting Chutzpah to work with requireJs/jasmine 2.0. This method worked for version 1.3 but now for jasmine version 2.0 chutzpah has stopped picking up the tests. I upgraded chutzpah to 3.1.1 for the jasmine 2.0 support as well. I did have to make a small change to load jasmine from requireJs to make it work but I figured this shouldn't affect chutzpah as it was just loading the html. Here's the command I run for chutzpah. chutzpah.console.exe path/to/SpecRunner.html

Dependency Injection vs. Managed Dependencies vs. Global Object

◇◆丶佛笑我妖孽 提交于 2020-01-14 09:24:11
问题 I'm working within a Javascript + BackboneJS (an MVC framework) + RequireJS framework, but this question is somewhat OO generic. Let me start by explaining that in Backbone, your Views are a mix of traditional Views and Controllers, and your HTML Templates are the traditional MVC Views Been racking my head about this for a while and I'm not sure what the right/pragmatic approach should be. I have a User object that contains user preferences (like unit system, language selection, anything else

RequireJS - jQuery is undefined when certain alias is given

天大地大妈咪最大 提交于 2020-01-14 08:13:08
问题 When setting the path for jQuery, whenever I am using: require.config({ paths: { 'jQuery': './libs/jquery-1.8.0.min' } }); Then: define(['jQuery'], function($) { console.log($); }; $ is gonna be undefined. However if I am using: require.config({ paths: { 'jquery': './libs/jquery-1.8.0.min' } }); Then: define(['jquery'], function($) { console.log($); }; Everything is working great all in a sudden. What's the issue with defining jQuery's alias with jQuery ? 回答1: This was discussed more over

Uncaught Error: Bootstrap's JavaScript requires jQuery with requirejs

萝らか妹 提交于 2020-01-14 05:42:05
问题 I am getting this error that says jQuery is not defined. bootstrap.js:8 Uncaught Error: Bootstrap's JavaScript requires jQuerybootstrap.js:8 (anonymous function) Bootstrap v3.3.0 jQuery JavaScript Library v2.1.3 requirejs require.config({ shim: { 'backbone': { deps: ['underscore', 'jquery'] }, 'backbone-validation': { deps: ['backbone', 'jquery'] }, 'jquerymx': { deps: ['jquery'] }, 'bootstrap': { deps: ['jquery'] } }, paths: { 'jquery': '/public/js/lib/jquery-2.1.3', 'jquerymx': '/public/js

Require.js (almond.js) Timing Off

本小妞迷上赌 提交于 2020-01-14 05:24:06
问题 I'm trying to use Almond.js and the Require.js optimizer to make a standalone file that can be used without Require.js. I've been able to successfully compile the file, and all the code runs, but there's one problem: the code executes in the wrong order. Let's say my main file (the one that's in the include= option passed to the optimizer) has the following: console.log('outside'); require(['someFile'], function(someModule) { console.log('inside'); window.foo = someModule.rightValue; }); and

External templates and “el” with Knockout and RequireJS?

孤者浪人 提交于 2020-01-13 18:55:14
问题 I am trying to use Knockout ViewModels as self-contained "widgets" that can be placed into any (or multiple) DOM nodes on the page. I had an approach in Backbone that seemed to work well and I'm trying to convert the concept to Knockout. In Backbone view I would do something like this, using the RequireJS text plugin to pull the template and inject it into the el: define(['text!templates/myTemplate.html',], function(templateHTML){ var view = Backbone.View.extend({ initialize:function() { //

Yeoman - task “requirejs” not found

柔情痞子 提交于 2020-01-13 16:03:54
问题 I'm having problems with yeoman, specifically, when I try to run grunt, it fails on the requirejs, stating simply that "The task 'requirejs' doesn't exist". That is really strange, since in my gruntfile I have the options definition for requirejs, and I also have it installed in the package.json file. Do you know what could be the problem? Thank you! // Generated on 2013-03-14 using generator-webapp 0.1.5 "use strict"; var lrSnippet = require("grunt-contrib-livereload/lib/utils")

Yeoman - task “requirejs” not found

那年仲夏 提交于 2020-01-13 16:02:28
问题 I'm having problems with yeoman, specifically, when I try to run grunt, it fails on the requirejs, stating simply that "The task 'requirejs' doesn't exist". That is really strange, since in my gruntfile I have the options definition for requirejs, and I also have it installed in the package.json file. Do you know what could be the problem? Thank you! // Generated on 2013-03-14 using generator-webapp 0.1.5 "use strict"; var lrSnippet = require("grunt-contrib-livereload/lib/utils")

TypeScript: import module with only statements

空扰寡人 提交于 2020-01-13 09:24:26
问题 I have a page-a.ts which would compile into page-a.js : alert('this is from page-a'); And I have a main.ts which compiles into main.js : import pageA = module('page-a') alert('this is from main'); And this is my tsc command line: tsc --module amd page-a.ts main.ts And I'm using requirejs like this: <script src="require.js" data-main="main.js"></script> I can't see the alert messagebox from page-a when loading the page. And in the generated scripts main.js , there is nothing about page-a . My