requirejs

Understanding r.js options w/grunt & backbone and relative paths

梦想的初衷 提交于 2019-12-12 09:57:07
问题 I'm trying to figure out how to use r.js. I keep getting errors thrown such a module path does not exist, or files getting dumped where they shouldn't be. I've got a single page application that is integrated with wordpress. I've adopted this backbone boilerplate for my general structure, although I've set things up quite different. My file structure is shown below. .Theme Folder ├── _assets | ├── _application | | ├── css | | ├── fonts | | ├── img | | ├── _js | | | ├── main.js //this is my

How to Use Assetic for requireJs

放肆的年华 提交于 2019-12-12 09:41:54
问题 I am trying to use require.js in synfony2 project. Here the code in the main twig file: <script data-main="{{ asset('bundles/web/js/main.js') }}" src="{{ asset('vendor/js/require.js') }}"> </script> The file vendor/js/require.js is correctly loaded but for the file bundles/web/js/main.js I get the message: Uncaught Error: Load timeout for modules: mainApp.js?201205021855 http://requirejs.org/docs/errors.html#timeout I am using RequireJS 1.0.8. Any idea how to fix the problem? Thanks. If I

RequireJS: How do I pass variables from one file to another?

廉价感情. 提交于 2019-12-12 08:54:56
问题 I'm using require with backbone + backbone-forms. I'm currently using RequireJS to seperate code into multiple files. I have models stored in separate files and want to keep form validators separately. However, I am unable to access variables defined in one files, in another file that depends on this one. What I get is Uncaught ReferenceError: isEmptyName is not defined . isEmptyName is defined in validators and used in model. Any feedback about RequireJS config is also appreciated. My config

Intellisense, auto completion with RequireJS in visual studio 2012

一世执手 提交于 2019-12-12 08:15:51
问题 I know javascript intellisense support trough _referencs.js in vs2012. At this moment, I am using RequireJS in my frontend, but I think I lost auto-completion supporting in javascript since I started using RequireJS. I found require.intellisense.js from here, but, unfortunatelly failed with it after several hours and tries. Is there anyone succeeded in getting auto-completion with RequireJS(version 2.1.2) in vs2012? 回答1: I got Intellisense to work inside RequireJS defined modules by following

Load external scripts with requirejs without access to config

笑着哭i 提交于 2019-12-12 07:48:40
问题 I'm trying to load the datatables javascript library in a plugin that I'm writing. The issue is that I get a conflict when I load the external resource, because datatables is conflicting with something when I call require. <!-- DataTables --> <script type="text/javascript" charset="utf8" src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/jquery.dataTables.min.js"></script> ... <script type="text/javascript"> require(['forum/admin/footer']); <-- crashes here, line 281 </script> Here's the

Disable uglyfying in r.js

♀尐吖头ヾ 提交于 2019-12-12 07:32:55
问题 I am looking for a way to prevent r.js (RequireJS' optimization script) from ugylyfying our JS-modules to maintain readability for debugging purposes. I expect the script (running on Node.js by the way) to have some command line option to be passed. Unfortunately, the documentation if this tool is rather poor. 回答1: Pass optimize=none on the command line to r.js, or include optimize: "none" in your build script. eg: ({ baseUrl: ".", paths: { jquery: "some/other/jquery" }, name: "main", out:

Import existing AMD module into ES6 module

帅比萌擦擦* 提交于 2019-12-12 07:15:17
问题 I have an existing application where I have AMD modules defined using RequireJS . I use "text" and "i18n" plugins for requirejs extensively in my project. I have been experimenting with ES6 modules lately and would like to use them while creating new modules in my application. However, I want to reuse the existing AMD modules and import them while defining my ES6 modules. Is this even possible? I know Traceur and Babel can create AMD modules from ES6 modules, but that only works for new

Don't invoke inherited method twice in ES6 classes

一曲冷凌霜 提交于 2019-12-12 06:49:10
问题 I'm moving from RequireJS to browserify (together with babelify) and try to rewrite my current modules to classes. For each of my RequireJS modules I have a method called eventHandler which handles all module specific events. Now when I extend a class, the parent class calls the subclass`s eventHandler method which leads to invoking the method twice. Parent class: 'use strict'; class Tooltip { constructor() { this.eventHandler(); } eventHandler() { // Module specific events } } module.exports

Are there any problems with nesting app-specific Backbone.js assets under common ones?

Deadly 提交于 2019-12-12 05:58:16
问题 I am working on structuring a large application that has several, discrete client-side applications. I am using Backbone.js for structure and Require.js to manage dependencies. Here is how I would like to model things so that I can have common functionality available to any of these applications: -- libs -- models -- collections -- templates -- views -- apps -- app_one -- libs -- models -- collections -- templates -- views -- app_two -- libs -- models -- collections -- templates -- views main

RequireJS search for app.app instead of app.js (where app.js is entry point specified in data-main)

女生的网名这么多〃 提交于 2019-12-12 05:56:38
问题 Problem: I have a trivial demo application which use requireJS. When require.min.js script loads, it tries to load entry-point script. But, the Problem is that instead of localhost:8090/js/app.js it tries to load localhost:8090/js/app.app and fails. Demo: You can see the whole app at GitHub. === Only if you don't like GutHub, here's my code === File structure ProjectRoot |-server.js |-public/ |-index.html |-js/ |-app.js |-lib/ |-require.min.js |-underscore.js |-backbone.js |-raphael.js |-app/