requirejs

Running a RequireJS/WireJS app using PhantomJS

笑着哭i 提交于 2019-12-22 09:14:32
问题 I'm trying to execute a basic app that uses RequireJS (2.1.8), WireJS (0.10.2) and PhantomJS (1.9.2): When running the app using PhantomJS (this is my goal), WireJS fails to load (see error below). When running the app using Chrome, it completes properly. Please help to point out the missing part for WireJS to run properly under PhantomJS. Following are my app files. 1) app.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>SaphirJS.core</title> <script data-main="app"

require js loading scripts from cdn fail

安稳与你 提交于 2019-12-22 08:22:50
问题 I am new to RequireJS, and for some reason I cannot load scripts through a CDN. My code: // site full url var siteUrl = window.location.protocol+"//"+window.location.host + "/fresh/"; // requirejs config requirejs.config({ baseUrl: siteUrl + "assets/js/", paths: { "plugins": "plugins", "scripts": "scripts", "jquery": "https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min", "jquery-ui": "https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min", "bootstrap": "https://netdna

Assigning variables to the window object in Backbone.js

只愿长相守 提交于 2019-12-22 08:07:14
问题 I am working on a big Backbone.js application. The code is modular structured using require.js . Now I see a lot of backbone code and tutorials doing this: window.app = ( window.app || {} ); after they will assign model definitions and Collection instances to that global object, like so: Task = Backbone.Model.extend({ /*...*/ }); Tasks = Backbone.Collection.extend({ /*...*/ }); window.app.Task = Task; window.app.Tasks = new Tasks(); // do this with all your models and collections I like this

How to dispatch events globally and inside requireJS objects?

被刻印的时光 ゝ 提交于 2019-12-22 07:45:11
问题 I am looking for a way to dispatch events globally and inside requireJS modules using javascript or jquery. I would like to be able to say within my js files: dispatchEvent(myCustomEventWithSomeData); and then in some other part of the application add a listener like so: addEventListener(“type Of Event”, executeThisFunction); is this possible using jquery? Or any other means? And will a potential solution work within requireJS modules which are not global javascript objects? Also, How can I

test not running on karma/jasmine/require.js 'There is no timestamp for *lib*!' error

空扰寡人 提交于 2019-12-22 06:47:15
问题 I change the code, extend some functionality and add new unittest for that. Now, when I run my unit tests with karma (test framework - jasmine ), it throw me an error 'There is no timestamp for /libs/angular-bootstrap/ui-bootstrap-tpls.js!' Uncaught Error: Script error for: angular-bootstrap http://requirejs.org/docs/errors.html#scripterror at http://localhost:9876/base/node_modules/karma-requirejs/lib/require.js?1379984163000:138 What I'm doing wrong? 回答1: It was my mistake completely. when

Bootstrapping a Backbone application

。_饼干妹妹 提交于 2019-12-22 06:42:54
问题 I have seen a couple of ways on how to do this, but I can never figure out which is the 'correct' way. Jeffrey Way from NetTuts+ and Addy Osmani instantiate a 'main' application view in order to kick off their applications. require(['views/app'], function(AppView) { new AppView(); }); Ryan Bates from Railscasts starts his application by instantiating a router which then handles subsequent requests: window.App = Models: {} Collections: {} Views: {} Routers: {} init: -> new App.Router()

Require.js to load all resources for an app, including Polymer

南笙酒味 提交于 2019-12-22 06:15:46
问题 I am building an app framework for a large, multi developer project. I am sold on the idea of using Require.js and Angular together to manage dependency and class loading. But now I want to use Polymer as well, because it's insanely cool. How could I use require.js to load polymer elements libraries just the same as my js ones? I like the idea of hanging on to require as THE one true way to load all my apps resources. I see how nice it is to be able to bundle template,script and style into

Play Framework 2.3.7: Static assets location not working in production

て烟熏妆下的殇ゞ 提交于 2019-12-22 05:16:15
问题 I have seen a few questions on this but cant seem to get to the bottom of it. I have a Play Framework 2.3.7 (Activator 1.2.12) site, when I run it in dev mode everything works fine. When I start it in production mode I get the following errors: [app] $ start [info] Wrote C:\Users\App\git\website2.0\target\scala-2.10\app_2.10-1.0- SNAPSHOT.pom [info] Main Scala API documentation to C:\Users\App\git\website2.0\target\scala- 2.10\api... [info] Compiling 57 Scala sources and 58 Java sources to C:

Loading jwplayer.js using Require.js

我与影子孤独终老i 提交于 2019-12-22 05:14:57
问题 So, I'm new to Require.js and I've been learning this library by loading various other libraries using Require.js methods. I've successfully load Knockout.js objects, Chart.js object, as well as custom Require.js defined objects. But I can't seem able to load jwplayer using Require.js. This is the error method I received: Uncaught TypeError: Cannot call method 'jwplayer' of undefined This is my sample code (the Knockout, Chart objects all loaded successfully) require(['jwplayer/jwplayer',

Karma and RequireJS: avoid duplication in src and test RequireJS config

荒凉一梦 提交于 2019-12-22 05:06:57
问题 For example, this test-main.js and this main.js has duplicated paths and shims. For large projects, there may be lots of them. I can even use grunt-bower-requirejs plugin to add installed Bower components into main.js, but after that, I have to copy them to test-main.js, either by hand or by program. Is there any convenient way to avoid this duplication, for example, tell RequireJS to include another config file? 回答1: I also hate to duplicate information. I work around that problem by using