requirejs

requirejs module is undefined

家住魔仙堡 提交于 2019-12-13 15:02:15
问题 I have following directory structure scripts modules tabs.js app.js I have following code in app.js define([ 'jquery', 'underscore', 'modules/tabs', ], function($, _, Tabs) { var App = (function() { var init = function() { console.log('app'); Tabs.init(); }; return { init: init }; }()); return App; }); following code in tabs.js define([ 'jquery', 'underscore', '../app' ], function($, _, App) { var Tabs = (function() { var init = function() { console.log('tabs init'); App.init(); }; return {

Loading spin.js with require.js

这一生的挚爱 提交于 2019-12-13 14:12:27
问题 I recently started a Javascript project and I am now moving it to require.js. Everything worked fine so far except for the spin.js library. I get the following error message when I try to access anything spin.js related: Uncaught ReferenceError: Spinner is not defined My requirejs.config looks like this: requirejs.config({ baseUrl: 'js', paths: { 'jquery': 'lib/jquery', 'spin': 'lib/spin', }, shim: { 'jquery' : { deps: [], }, 'spin' : { deps: [], exports: 'Spinner' }, } }); A sample module

When using the requireJS optimizer, what's the advantages of buildlayered javascript?

Deadly 提交于 2019-12-13 14:09:14
问题 I'm trying my first attempts with the requireJs optimizer r.js (here) to prepare an application for production. I can get everything to work and can uglify all of my js into a single main.js file, but one file, many questions... Basic questions : What is the Javascript buildlayer requireJs is talking about? My single file? Right now I only optimized one module main.js , which bundles all dependencies into a single file (jquery, jquery-mobile, plus everything else required to get my app

Lazy loading of modules in Nodejs

拜拜、爱过 提交于 2019-12-13 13:21:47
问题 My first question is : Who is responsible to handle require statements in a Nodejs application ? is it Node itself ? or CommonJS ? or RequireJS ? Is CommonJS included in Node ? what about RequireJS? Now my second question : I have an if-else statement , which decides if we are rendering on server side or client side. I want to load different libraries when it's rendering on client side or server side. Is it possible to load the modules in runtime ? exactly at the moment it's required ? if

Knockout.js won't be recognized after using require.js

白昼怎懂夜的黑 提交于 2019-12-13 10:19:51
问题 Calling require.js before knockout.js throws the following message: Uncaught ReferenceError: ko is not defined Assuming I have knockout.js at the very top of the combined file, I have this: <script type="text/javascript" src="/bower_components/requirejs/require.js"></script> <script type="text/javascript"> requirejs.config({ paths: { text: '/bower_components/text/text' }, }); requirejs([ '/bower_components/text/text.js' ]); </script> <script type="text/javascript" src="/js/dist/combined.min

How to make a fallback to a whole folder in requireJS

我是研究僧i 提交于 2019-12-13 08:26:00
问题 I understood how I can config in requireJS a fallback for a single file like this: var skin = "christmas"; requirejs.config({ paths: { languagesLocal : [ BaseUrl + skin + '/js/languagesLocal', BaseUrl + "default" + '/js/languagesLocal' ] } }); so incase there is no "chrismas" skin I land to the default script. Now - my question is - How do I make a complete folder to be the fallback folder? so incase one file does not exist in the skin folder - it will have a fallback in another folder. I

MegaPixImage Error From FineUploader When Loading Page with RequireJS

大兔子大兔子 提交于 2019-12-13 07:35:16
问题 I am refactoring my application to use RequireJS (using the sbt-web abstraction in Play Framework, but that isn't germane). First, I simply sought to use a shim to load FineUploader since it isn't AMD-compatible, but I encountered a " MegaPixImage is not defined " error. That seemed weird to me since FineUploader has no dependencies (as third-party stuff is built-in). But after seeing this Stack Overflow post, I downloaded the library separately and set up my RequireJS configuration this way

error loading jquery-ui in require.js config for fancytree plugin

我们两清 提交于 2019-12-13 07:29:18
问题 I'm trying to load a jQuery control called fancytree and this control depends on jquery-ui. I'm getting an error saying that it hasn't loaded jquery-ui from the path I've given. Fancytree also depend on another file called fancytree.table as well. My directory structure is like this js /app .... /lib /jquery /underscore /backbone /vendor /jquery-ui /fancytree Error: jquery.js:2 Uncaught Error: Fancytree assertion failed: Fancytree requires jQuery UI (http://jqueryui.com)(…) config: require

Crossroads.js and require.js

梦想与她 提交于 2019-12-13 07:09:55
问题 I want to use crossroads.js with require.js to determine what file to require based on the URL. I have crossroads set as a dependancy in a Router.js file and if I console.log(crossroads) straight out from the crossroads.js file I get the crossroads object. However it isnt getting passed to the Router.js file, its null or undefined... Wonder if anyone has had this issue before? Cheers in advance. 回答1: Crossroads.js works with RequireJS since the beginning (I use RequireJS on all my projects)

Create node module and <script> in one file

限于喜欢 提交于 2019-12-13 07:00:39
问题 How can I write my source file so that it can be "required" and <script src=""> from one code base? I have hit a rare function that makes sense on both side of the app and would like to only maintain one version. Is it possible to make a script be usable on both sides assuming it does not use any platform specific functions? 回答1: The script itself: var myFunc = function(){ }; if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') module.exports = myFunc; Now you can