Dojo require() and AMD (1.7)

The dependency array format: define([“a”, “b”, “c”], function (a, b, c) { }); can indeed be annoying and error-prone. Matching up the array entries to function parameters is a real pain. I prefer the require format (“Simplified CommonJS Wrapper”): define(function (require) { var a = require(“a”); var b = require(“b”); var c = require(“c”); }); … Read more

What is the main difference between require() and define() function in dojo and when would we use either?

require and define are part of the asynchronous module definition (AMD) API. You use define to define a module that can be consumed by other code. Generally, define will be used in a javascript file. The javascript file is defining a module. All Dojo files use define. You use require when you are not defining … Read more

require.js: Access all loaded modules

Yes, require.s.contexts._.defined is an object which its keys are the module names and the values include the value returned from that module. require.s.contexts._.defined includes all the modules (either define() or require() such as the Javascript file that is the starting point of the program and is indicated using data-main for RequireJS).

How to load bootstrapped models in Backbone.js while using AMD (require.js)

This is how we bootstrap data in a way that it doesn’t pollute the global namespace. Instead it uses require.js exclusively. It also helps you provide the initial app configuration based on variables within the template. Within your rendered page <script src=”https://stackoverflow.com/questions/9916073/require.js”></script> <script> define(‘config’, function() { return { bootstrappedAccounts: <%= @accounts.to_json %>, bootstrappedProjects: <%= @projects.to_json(:collaborators … Read more

How to achieve lazy loading with RequireJS?

Is this actually possible? Are there black magicks in RequireJS that looks for calls to require() without actually triggering the doStuff route? When you use the ‘sugar’ syntax it uses Function.prototype.toString and a regex to extract your references to require and then lists them as dependencies before running the function. Basically it becomes the normal … Read more

RequireJS: Loading modules including templates and CSS [closed]

You can specify the template as a dependency using the text! module like you have shown. I do this with Mustache Templates. However Require.js does not explicitly support css files. Here is the official explanation, it’s explained pretty well: http://requirejs.org/docs/faq-advanced.html#css Edit: Feb 2012. Templates such as handlebars can also be precompiled and included just like … Read more

What’s the difference between Require.js and simply creating a element in the DOM? [closed]

What advantages does Require.JS offer in comparison to simply creating a element in the DOM? In your example, you’re creating the script tag asynchronously, which means your needMe() function would be invoked before the need_me.js file finishes loading. This results in uncaught exceptions where your function is not defined. Instead, to make what you’re suggesting … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)