requirejs

How to load koLite with requirejs?

南楼画角 提交于 2020-01-17 10:57:50
问题 This is from knockout.dirtyFlag.js ;(function (ko) { ko.DirtyFlag = function (objectToTrack, isInitiallyDirty, hashFunction) { hashFunction = hashFunction || ko.toJSON; var _objectToTrack = objectToTrack, _lastCleanState = ko.observable(hashFunction(_objectToTrack)), _isInitiallyDirty = ko.observable(isInitiallyDirty), result = function () { var self = this; self.isDirty = ko.computed(function () { return _isInitiallyDirty() || hashFunction(_objectToTrack) !== _lastCleanState(); }); self

How to load koLite with requirejs?

假装没事ソ 提交于 2020-01-17 10:55:26
问题 This is from knockout.dirtyFlag.js ;(function (ko) { ko.DirtyFlag = function (objectToTrack, isInitiallyDirty, hashFunction) { hashFunction = hashFunction || ko.toJSON; var _objectToTrack = objectToTrack, _lastCleanState = ko.observable(hashFunction(_objectToTrack)), _isInitiallyDirty = ko.observable(isInitiallyDirty), result = function () { var self = this; self.isDirty = ko.computed(function () { return _isInitiallyDirty() || hashFunction(_objectToTrack) !== _lastCleanState(); }); self

node redis, variables are shared between clients?

筅森魡賤 提交于 2020-01-17 06:08:15
问题 node's redis's async nature is killing me. I see when message handling is switched from one client to another client, variables I believed to be independent looks be overriden by other clients. I don't know why variable is shared between the two clients. var subscriber = redis.createClient(port, host); var client = redis.createClient(port, host); var requirejs = require('requirejs'); requirejs(['my-function'], function(myFunction) { subscriber.subscribe('CHANNEL'); subscriber.on('message',

Requirejs in node executing call twice for no reason?

喜欢而已 提交于 2020-01-17 03:42:08
问题 Trying to get my head around using requirejs in node, when I run a sync call as described in the RequireJS in Node manual with the following... //Retrieves the module value for 'a' synchronously var a = requirejs('a') ) However when I've tried this approach it executes the request twice? part0_start.js... var requirejs = require('requirejs'); requirejs.config({ nodeRequire : require }); var part1_setup = requirejs( 'part1_setup' ) console.log( 'part1_setup complete') part1_setup.js...

AMD与CMD区别(玉伯) - 2015

我怕爱的太早我们不能终老 提交于 2020-01-17 02:05:09
原话 学习下 AMD 规范在这里: https:// github.com/amdjs/amdjs- api/wiki/AMD CMD 规范在这里: https:// github.com/seajs/seajs/ issues/242 AMD 是 RequireJS 在推广过程中对模块定义的规范化产出。 CMD 是 SeaJS 在推广过程中对模块定义的规范化产出。 类似的还有 CommonJS Modules/2.0 规范,是 BravoJS 在推广过程中对模块定义的规范化产出。 还有不少⋯⋯ 这些规范的目的都是为了 JavaScript 的模块化开发,特别是在浏览器端的。 目前这些规范的实现都能达成 浏览器端模块化开发的目的 。 区别: 1. 对于依赖的模块,AMD 是 提前执行 ,CMD 是 延迟执行 。不过 RequireJS 从 2.0 开始,也改成可以延迟执行(根据写法不同,处理方式不同)。CMD 推崇 as lazy as possible. 2. CMD 推崇 依赖就近 ,AMD 推崇 依赖前置 。看代码: // CMD define(function(require, exports, module) { var a = require('./a') a.doSomething() // 此处略去 100 行 var b = require('./b') //

Unable to load module that uses a named define call

馋奶兔 提交于 2020-01-15 12:21:52
问题 I am using RequireJS & its working fine for some modules. Recently, I added two test modules (code for the modules seems to be fine). I am importing them in my main (javascript) file and I can see that the file get imported in the browser. However, I see the following error message and I cannot troubleshoot properly what might be causing this issue. Any suggestions to fix or troubleshoot this will be greatly appreciated. Error Message in browser Error: No define call for urlCore/urlTest http:

RequireJS configuration for jQuery

安稳与你 提交于 2020-01-15 11:23:40
问题 I'm trying to configure RequireJS to load jQuery from a different folder on my site than the /Scripts folder where everything else lives. I'm watching the page load with Fiddler, and I always see the jQuery request go out for /Scripts/jquery.js instead of the right URL. In my markup, I have this: <script src="@Url.Content("~/Scripts/require.js")" type="text/javascript" data-main="@Url.Content("~/Scripts/main")"></script> In /Scripts/main.js I have this: require.config({ waitSeconds: 10, paths

RequireJS configuration for jQuery

丶灬走出姿态 提交于 2020-01-15 11:22:55
问题 I'm trying to configure RequireJS to load jQuery from a different folder on my site than the /Scripts folder where everything else lives. I'm watching the page load with Fiddler, and I always see the jQuery request go out for /Scripts/jquery.js instead of the right URL. In my markup, I have this: <script src="@Url.Content("~/Scripts/require.js")" type="text/javascript" data-main="@Url.Content("~/Scripts/main")"></script> In /Scripts/main.js I have this: require.config({ waitSeconds: 10, paths

RequireJS: Automatically load configuration script after a library module has been loaded

╄→尐↘猪︶ㄣ 提交于 2020-01-15 10:29:47
问题 I am refactoring the JavaScripts of our project to use RequireJS for on-demand loading of required modules instead of adding a bunch of script tags to the HTML template. We use a few libraries like jQuery, DataTables plugin for jQuery etc. and some of those libs need some initialization after they have been loaded. I. e. the default settings for DataTables must be set after the lib has been loaded and before it is being used the first time. At the moment I do this in a main script which is

Using AMD module as an Aurelia ViewModel

孤者浪人 提交于 2020-01-15 07:27:10
问题 I was playing with Aurelia and seems pretty nice, I use Durandal for some projects and this definitively suit my needs. Use the new class definition from EC6 is awesome. But now I'm preparing something in which I need to use a classic AMD modules with requireJs, something like this one: define("testModule", [], function() { "use strict"; console.log('testModule loaded'); var testModule = function() { var that = this; this.variable = 10; that.getVariable = function(){ alert('function executed