requirejs

requirejs race condition - how to block until previous file retrieved

本秂侑毒 提交于 2019-12-12 18:35:38
问题 common_tempaltes file is not a requirejs file - rather a file that defines a global variable. common_templates needs hogan . they both are requested more or less at the same time, but race condition is in affect. common_templates sometimes wins so the code fails with "hogan not loaded yet". require(['module1', 'hogan', 'common_templates'], function(Module){ Module.do_stuff() // this module also requires hogan and common_templates to be loaded }); other than nested require, is there a built in

How does AMD (require.js) handle multiple classes in a single non-amd js file?

拈花ヽ惹草 提交于 2019-12-12 17:28:08
问题 I'm using a bunch of components from the MootoolsMore library which are all compiled into a single .js file. Is there a way to define the library once in the shim and have access to all the class with in it? The following doesn't work, but how would I do something like this? shim:{ mootoolsMore:{ deps : ["mootools"] exports : ["Slider", "Sortables"] } } // then inside my module I could access the Slider component like so define( function(require) { var Slider = require('mootoolsMore').Slider

DataTables+RequireJS: Cannot read property 'defaults' of undefined

二次信任 提交于 2019-12-12 16:32:01
问题 I have downloaded the full package of DataTables with all its module, since it can't be accessed through the CDN URL: https://www.datatables.net/download/ (all options selected) I'm trying to make it run with RequireJS , the same dependency system is used throughout the whole DataTables package, so it shouldn't be failing. JSFiddle (edited for the purpose of JSFiddle): http://jsfiddle.net/42ucpwee/1/ My configuration results in this error: datatables.js:93165 Uncaught TypeError: Cannot read

require.js alternative way to require?

吃可爱长大的小学妹 提交于 2019-12-12 16:09:21
问题 New to require.js. I have this: define([ 'jquery', 'underscore', 'backbone', 'views/sidebar', 'views/dashboard', 'views/users', 'views/venues', 'views/payments' ], function($, _, Backbone, SidebarView, DashboardView, UsersView, VenuesView, PaymentsView) { var Router = Backbone.Router.extend({ routes: { '/dashboard': 'showDashboard', '/users': 'showUsers', '/venues': 'showVenues', '/payments': 'showPayments' } }); var initialize = function() { var router = new Router(); Backbone.history.start(

Babel/RequireJS + typeof “RangeError: Maximum call stack size exceeded”

☆樱花仙子☆ 提交于 2019-12-12 13:30:36
问题 I have a very basic JS error and I'm quite ashamed to not be able to solve it... I'm developping with ES6 and Babel and I'm making some experiments. Please note I'm using these arguments with Babel: --presets es2015 --plugins transform-es2015-modules-amd I have a simple module: "use strict"; export default class Inspector { static inspect() { console.log(this.prototype.myMethod); console.log(typeof this.prototype.myMethod); } } I use this module like that: "use strict"; import Inspector from

What are the difference between $(document).bind('ready', function) and $(document).ready(function() {})

[亡魂溺海] 提交于 2019-12-12 12:33:15
问题 I want to upgrade from requirejs version 2.0.0 to 2.1.5 Here is the code: define(['jquery', 'test.js'], function ($, test) { var test = new $.test({ //options }); .... }); test.js (function($) { var registerEvents = function() { //dosth }; $.test = function(options) { $(document).bind('ready', function() { registerEvents(); }); ... return test; } ... }); In version 2.0.0, requirejs holds the dom ready event till all resources are downloaded, so it worked correctly https://github.com/jrburke

RequireJS + Waypoints : Object [object Object] has no method 'waypoint'

Deadly 提交于 2019-12-12 12:01:12
问题 I can't use waypoints with RequireJS although everything looks good. Here is my code: http://jsfiddle.net/7nGzj/ main.js requirejs.config({ "baseUrl": "theme/PereOlive/js/lib", "paths": { "app":"../app", "jquery": "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min" }, "shim": { "waypoints.min": ["jquery"] } }); requirejs(["app/common"]); common.js define([ 'jquery', "waypoints.min", ], function () { $(function () { console.log($.waypoints); $('#loading').waypoint(function (direction) {

Workaround for MVC misbehaviour with missing trailing slash

淺唱寂寞╮ 提交于 2019-12-12 11:34:14
问题 This is in index.cshtml. <script>alert(window.location.href);</script> <script type="text/javascript" src="~/Scripts/require.js" data-main="App/main"> </script> This fails when the URL lacks a trailing slash. This URL http://host/appname/ results in expected behaviour (the browser loads /appname/App/main.js) but the same URL without a trailing slash causes the browser to attempt to load this /App/main.js resulting in a 404 not found. I tried framing it like this <script>alert(window.location

Backbone + JQuery Mobile + RequireJS

删除回忆录丶 提交于 2019-12-12 10:28:16
问题 I am having a big proglem with RequireJS. This configuration works randomly. I dont know why, once it works and once it doesn't: requirejs.config({ baseUrl: 'js', urlArgs: "bust=" + (new Date()).getTime(), paths: { jquery: 'libs/jquery/jquery-1.10.2.min', underscore: 'libs/underscore/underscore-min', backbone: 'libs/backbone/backbone-min', marionette: 'libs/marionette/backbone.marionette', cordova: 'libs/cordova/cordova-1.9.0', jquerym: 'libs/jquery-mobile/jquery.mobile-1.4.0' }, shim: {

Javascript AMD pattern confusion - persisting property values

南笙酒味 提交于 2019-12-12 10:23:26
问题 So I am trying to get my head around the javascript AMD pattern using requireJS. My experience with JS is limited and no doubt this is what is hampering me. I would not be surprised if I am pointed in the direction of "JS for Dummies". If anyone can bear to help me with this I would be VERY grateful. I have defined a module called "security" which has the following definition - cut down a bit. define(['services/storage'], function(storage) { var security = { authToken: {}, loadAuthToken: