requirejs

Backbone Marionette: Marionette.Application causing Require.js module load error, “'Error: Module name 'App' has not been loaded yet for context: _”

为君一笑 提交于 2019-12-10 00:12:23
问题 I'm trying to include the App instance to use it's event aggregator as shown here I get an error when I include the instance in a view. Kicking things off in the Requirejs config file, from App.Bootloader.js: require(['App'], function (App){ App.start(); }); from App.js: define(function (require){ //...requisite includes $, _, Backbone, Marionette ... var Layout = require('Layout'); var App = new Marionette.Application(); App.addRegions({ main: '#view_content' }); App.addInitializer(function

Debugging/Navigating JS Code in Visual Studio

江枫思渺然 提交于 2019-12-09 20:58:28
问题 Is there anyway to enable f12 or find all references across Javascript files in Visual Studio ? I'm using requireJS to register the js files in my SPA. I'm using BackboneJS as well. Any tips for flipping through relavent code in Visual Studio like I can with C#/.net code? I've searched around online and investigated myself but couldn't find anything. Thank you 回答1: to enable F12 navigation to JS function source defined in another .js file you need to add the following line to the top of the

using requireJS to dynamically load js files

拜拜、爱过 提交于 2019-12-09 20:44:54
问题 I'm creating a RPG. I would like to dynamically load NPC dialog js files depending on the current level. Originally, I was doing <script type="text/javascript" src="js/npc_dialog_level_1.js"></script> at the top of my game.js file... but don't want to keep doing that for each npc_dialog.js file. I would rather do something like: if (map == 1) { require(js/npc_dialog_level_1.js); if (map == 2) { require(js/npc_dialog_level_2.js); I was following requireJS's tutorial, but I'm not clear on: a)

RequireJs dependency always undefined

不问归期 提交于 2019-12-09 19:48:53
问题 I am using require Js and am getting rather confused as to why my modules are loading but dependencies are always undefined and even upon using require.defined() function to check if my module has been loaded it indeed has been but when i use the require([deps],function(deps){}); all of my dependencies are undefined (except for jquery ,underscore and knockout) my file structure is as follows my file structure is as follows scripts | | main.js | |_________BusinessScripts | | | | jquery.js | |

Can the 'this' keyword be used inside a RequireJS module?

試著忘記壹切 提交于 2019-12-09 18:22:31
问题 I defined a RequireJS module (see below). It is a collection of functions that are needed on every page on a site. One of the functions in the returned object, initTwitter(), needs to call another function, shortenURL(), in the same object. I am getting a console error that reads, "TypeError: this.shortenURL is not a function." All of these functions were originally in a regular Javascript singleton object, and the code ran fine. I'm new to RequireJS, so I'm not sure if the this keyword works

AngularJS, requireJS and ngRoute

為{幸葍}努か 提交于 2019-12-09 18:10:07
问题 I'm building an Address Book to learn angular and have it working nicely until I try to use the route manager. The issue is with loading the angular route manager via require. I'm getting the following error 'Uncaught object'. There have been questions about this but they have been removed by the user, and other answers point to not having included the ngRoute dependancy in the ng.module dependancy list, or aren't using require at all. I'm not having much luck finding an answer! I have the an

Loading mustache using requirejs

旧时模样 提交于 2019-12-09 14:42:39
问题 I would like to load and use mustache by requirejs. Maybe this question has already asked: AMD Module Loading Error with Mustache using RequireJS Anyway I am trying to figure out how can I fix my code: main.js require.config({ paths: { jquery: 'libs/jquery/jquery', underscore: 'libs/underscore/underscore-min', backbone: 'libs/backbone/backbone-optamd3-min', mustache: "libs/mustache/mustache" } }); require([ 'views/app' ], function(AppView){ var app_view = new AppView; }); app.js define([

understanding requirejs paths

▼魔方 西西 提交于 2019-12-09 14:27:24
问题 Using requirejs my main.js looks like this requirejs.config({ baseUrl: '/javascript/', paths: { jquery: 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min', async: 'requirePlugins/async', hbs: 'hbs' }, waitSeconds: 7 }); define(['common'], function () { loadFonts(); }); The main.js is included in the page with a script call <script data-main="/javascript/main.js" src="/javascript/require-2.0.1.js"></script> Common is the basic function for the website, jquery doc ready function etc

How to use UMD in browser without any additional dependencies

谁都会走 提交于 2019-12-09 14:14:41
问题 Suppose I have an UMD module like this (saved in 'js/mymodule.js' ): (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (factory((global.mymodule = global.mymodule || {}))); }(this, function (exports) { 'use strict'; function myFunction() { console.log('hello world'); } })); How can I use this module in an HTML file like this? (without requirejs, commonjs,

usemin revved filenames and requirejs dependencies

可紊 提交于 2019-12-09 11:47:49
问题 I'm running into the following problem with requirejs and usemin: I want to setup a multipage application, where I dynamically load modules that only contain page specific functionality (e.g. about -> about.js, home -> home.js). I could go ahead and pack everything in a single file, but that just leads to a bigger file size and overhead on functionality that isn't necessary on each site! (e.g. why would I need to load a carousel plugin on a page that doesn't have a carousel!) I checked out