requirejs

Cross Domain Modules with Require.js not adding “.js” for submodules

对着背影说爱祢 提交于 2019-12-08 08:20:36
问题 I'm having trouble getting cross domain modules to work in require.js I have a submodule on othersite.com // othersite.com/js/submodule.js define(function() { return { test: "Submodule here!" }; }); And a module on othersite.com that uses that submodule // othersite.com/js/mainmodule.js define(['./submodule'], function(SubModule) { return { test: "Main Module Here" + SubModule.test, }; }); Now on mainsite.com I have a module that tries to reference mainmodule on othersite.com. // mainsite.com

RequireJS module's dependencies not being evaluated

自闭症网瘾萝莉.ら 提交于 2019-12-08 08:14:50
问题 I have the following (extremely simple) module definition, in CoffeeScript: # backbone/routers/appointments_router.js.coffee define ["app", "underscore", "backbone"], (App, _, Backbone) -> console.log(Backbone) And here's my config and stuff: # application.js.coffee requirejs.config paths: underscore: "lodash.min" backbone: "backbone" appointmentsRouter: "backbone/routers/appointments_router" "backbone-relational": "backbone-relational" requirejs ["app", "underscore", "backbone",

Lazy-load MonacoEditor

风流意气都作罢 提交于 2019-12-08 08:10:18
问题 I have the following code to load MonacoEditor in index.html of my AngularJS website: <link rel="stylesheet" data-name="vs/editor/editor.main" href="/monaco-editor/min/vs/editor/editor.main.css" /> <script src="/monaco-editor/min/vs/loader.js"></script> <script src="/monaco-editor/min/vs/editor/editor.main.nls.js"></script> <script src="/monaco-editor/min/vs/editor/editor.main.js"></script> <script> require.config({ paths: { 'vs': '/monaco-editor/min/vs' }}) console.log(monaco) </script>

Loading entire modules at once using backbone.js (multiple views, models, collections)

安稳与你 提交于 2019-12-08 08:07:59
问题 I've been toying with the idea of rebuilding a very antiquated in-house CMS using backbone.js so that I build more of an app than a website. So far I'm comfortable with backbone and I've added in require.js to break the application into modules but there's one small thing that's bothering me. My impression of backbone is that it would be possible to deliver the application to the user in a single initial payload but since adding require.js all models, collections, views, and templates are

Switching between singleton and prototype scope using RequireJS

自古美人都是妖i 提交于 2019-12-08 07:51:27
问题 Spring has very useful option, that whey I define a bean, I define a scope. If it's singleton , only one instance is created. By prototype , each time a bean is required, a new instance is created. RequireJS provides by default singletons, so with such simple module: Singleton.js define([], function() { console.log('Instance initialization') var items = [] var singleton = { getItems: function() { return items }, setItems: function(newItems) { items = newItems }, addItem: function(item) {

load javascript file before onload with requirejs

时光总嘲笑我的痴心妄想 提交于 2019-12-08 07:51:25
问题 I would like to use requireJS. However, I have a lib that needs to be loaded before the DOM. However, this is not what happens with requireJS <html> <head> <script data-main="/app" src="/require.js"></script> </head> <body> <bar-foo/> </body> </html> With app.js require.config({ paths: { 'customElement': '/customElement', 'barfoo': '/barfoo' }, shim: { barfoo: { deps: [ 'customElement' ] } } }); define(['barfoo'], function() { .... } For example, if I simply load this script directly in the

backbone app not calling in xsl but works fine in my local

空扰寡人 提交于 2019-12-08 06:57:17
问题 I am trying to call the backbone app through xsl... its working fine...but the problem is when i put inside a function its not working... i tested with console.log inside that function..i am able to see console log...but its not calling backbone app,, providing my code below... the same function working fine when i dont put in xsl thats is when i test it in my local... do i need to include anything in my xslor upgrade xsl...i dont see my app rendering in browser through xsl...but it works

$.mustache() is defined, but Mustache isn't defined when mustache() is invoked

亡梦爱人 提交于 2019-12-08 06:41:14
问题 I am trying to use Mustache along with requireJS and jQuery, and it seems that it is being loaded into the browser since Chrome's console outputs correctly: >$.mustache <function (template, view, partials) { return Mustache.render(template, view, partials); } But when I try to use the mustache function it gives the error ReferenceError: Mustache is not defined and points to line 588 in the mustache.js file itself: $.mustache = function (template, view, partials) { return Mustache.render

gapi is not defined error comes when using with requirejs

亡梦爱人 提交于 2019-12-08 06:27:37
I am trying to load google API files with requireJS, but getting an error of, One think I can understated that GP file is loading before the google's call "gp.js:23 Uncaught ReferenceError: gapi is not defined" here is the code for gp.js file function logout() { gapi.auth.signOut(); location.reload(); } function login() { var myParams = { 'clientid' : '900278902057-ppqm358qrhki089danipqguj3i4ir70i.apps.googleusercontent.com', 'cookiepolicy' : 'single_host_origin', 'callback' : 'loginCallback', 'approvalprompt':'force', 'scope' : 'https://www.googleapis.com/auth/plus.login https://www

Require.js load CDN bootstrap and CDN popper

﹥>﹥吖頭↗ 提交于 2019-12-08 05:30:23
问题 I wish to use require.js to load CDN hosted bootstrap and jquery. I realise that this question has been asked before (Refer Steve Eynon's answer to Issue Loading PopperJS and Bootstrap via RequireJS, Even After Using Recommended PopperJS Version), but the posted answers do not work for me. What I have tried so far The host html file has content ... <!doctype html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap