requirejs

Grunt task to optionally include an AMD module for different environment

倖福魔咒の 提交于 2019-12-14 03:59:41
问题 I'm developing a web app using Require.js for AMD and amplify.request to abstract away my AJAX calls. The other advantage to amplify.request is that I've defined an alternative module containing mocked versions of my requests that I can use for testing purposes. Currently, I'm switching between the two versions of my request module by simply commenting/un-commenting the module reference in my main.js file. What I'd love to do is use Grunt to create different builds of my app depending on

Combining files using requirejs and grunt

好久不见. 提交于 2019-12-14 03:44:41
问题 I am trying to combine files using the grunt plugin for requirejs: https://www.npmjs.org/package/grunt-contrib-requirejs Here is the configuration: requirejs: compile: options: #appDir: './' baseUrl: "client" mainConfigFile: "client/test1.js" name: "test1" out: "build/test.js" onModuleBundleComplete: (data) -> outputFile = data.path fs.writeFileSync(outputFile, amdclean.clean( 'filePath': outputFile )) wrap: start: "" end: "" Here are the input and output javascript Input: test1.js var x =

RequireJS - custom js-library not working

蹲街弑〆低调 提交于 2019-12-14 03:18:49
问题 I'm trying to include a custom js-library/script in my RequireJS-config but it doesnt seem to work. So I hope someone can help me out. I'm using RequireJS in combination with Backbone and Handlebars, so just to mention it... In my Require config I have: require.config({ paths: { jquery: 'lib/jquery/jquery', backbone: 'lib/backbone/backbone', // Templating. handlebars: 'lib/handlebars/handlebars', // Plugins. jqueryEffects: 'lib/jquery/jquery.effects', ... //some more libraries }, shim: {

which library is overriding the $? [duplicate]

十年热恋 提交于 2019-12-14 02:24:42
问题 This question already has answers here : jquery, bootstrap 3.0, and requirejs. can't use bootstrap's functions (2 answers) Closed 5 years ago . I'm trying to use jquery/bootstrap/ and requirejs Loading js files works perfectly and I checked that bootstrap sets $.fn.tab = someFunction; but then, inside requirejs's callback function, calling $(foo).tab('show') results in an error saying that tab is not available for the object. Uncaught TypeError: Object [object Object] has no method 'tab'

Setting breakpoints in viewmodels in Durandal

烈酒焚心 提交于 2019-12-13 23:36:24
问题 How do I use Google Chrome's (F12) feature to set breakpoints in Durandal's viewmodels? 回答1: Load the page you want to debug Hit F12 in Chrome click on the 'Sources' tab In the pane on the left you should be able to see all your different view model js files Choose one of the js files by clicking on it Set a breakpoint by clicking on the code line number in the source code view You can refresh the browser page and your breakpoints will remain intact 来源: https://stackoverflow.com/questions

RequireJS and AngularJS

久未见 提交于 2019-12-13 22:24:22
问题 I'm integrating RequireJS and AngularJS. This is fairly complex problem and I'm struggling to articulate my problem in a Stackoverflow post, so here is a screencast of my issue. Sit back, relax, watch the weirdness.. http://goo.gl/02CGVe Basically when I load my core dependencies with RequireJS Angular seems to compile the page and then my elements dissapear off the page. I'm at a loss. Any help would be greatly appreciated! Sidenote: I'm not building a SPA, so there is no need for ngRoute in

require.js Uncaught TypeError: Property '$' of object #<Object> is not a function

↘锁芯ラ 提交于 2019-12-13 21:05:53
问题 I'm trying to use require.js for the first time, however I'm getting the error: Uncaught TypeError: Property '$' of object # is not a function. require.config({ shim: { "jquery": { exports: '$' }, underscore: { exports: '_' }, backbone: { deps: ['underscore', 'jquery'], exports: 'Backbone' } }, paths: { jquery: '//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min', underscore: '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min', backbone: '//cdnjs.cloudflare.com/ajax

RequireJS randomly loads wrong filename with AMD modules

故事扮演 提交于 2019-12-13 18:30:07
问题 I have my config (main.js) defined as: require.config({ urlArgs: "bust=" + (new Date()).getTime(), paths: { jquery: 'jquery-1.8.3.min', knockout: 'knockout-2.2.0', komapping: 'knockout.mapping-latest', token: 'jquery.tokeninput' }, shim: { 'token': ['jquery'] } }); EDIT main.js is a shared configuration. I have several pages that all use the same setup and I don't want to need to modify version-specific filenames all over the place in my project. /EDIT and included in the page as: <script src

jquery validate not loaded requirejs

烂漫一生 提交于 2019-12-13 16:26:24
问题 I have a main module in RequireJS: require([ 'jquery', 'jquery.validate', 'jquery.validate.unobtrusive' ], function ($) { $(document).ready(function () { var validator = $("form").validate(); if ($("#txtFirstName").val() !== "") validator.element("#txtFirstName"); }); }); When I load this page, I get a JavaScript error: TypeError: $(...).validate is not a function var validator = $("form").validate();** I don't now why? All scripts are loaded: 回答1: You'll need to configure shim to "wire" the

r.js - excluding specific list of files

女生的网名这么多〃 提交于 2019-12-13 15:30:47
问题 Hello evryone, I'm trying to find a way to make the r.js not to copy all the files form my /lib/ directory except for (for example) jquery.js and require.js . I'm using fileExclusionRegExp option to exclude all *.js files except for the above mentioned. fileExclusionRegExp: '\/lib\/(?!jquery|require).*\.js' But after the optimization, I can still see that other files have been copied over too. Is there anything I'm doing wrong ? Or is the regex incorrect? Thanks in advance 回答1: The problem