requirejs

Get object from view to display in text! plugin of backbone project

流过昼夜 提交于 2019-12-12 02:48:10
问题 I am trying to display customer's sale history in a tab. When customer first click in to History tab, the data is displayed from Local Storage of the browser, other wise if the customer search for any specific information, data will gotten from web service(REST) in the form of JSON data. CustomerView.js define(["jquery" , "underscore" , "backbone", "text!templates/Customer/profile.html", "text!templates/Quotation/sale.html", "Quotation" ],function($,_,Backbone,CustomerProfile,SaleHistory

RequireJS Module name “requirejs” has not been loaded yet for context. use require([])

蹲街弑〆低调 提交于 2019-12-12 02:37:59
问题 I know there is a help page for a module not loading, however, this seems like a different case due to the fact that requirejs cannot find requirejs. I installed all of my dependencies using npm. My main script is in the project root, which is called by an html page. Here is a snippet from the web page: <script type="text/javascript" data-main="./airportLeafletScript.js" src="node_modules/requirejs/require.js"></script> And then the header of airportLeafletScript.js looks like this: var

How do I test AngularJS controllers using RequireJS?

那年仲夏 提交于 2019-12-12 02:33:46
问题 Here's my Jasmine spec, define(['app', 'angular', 'angularResource', 'angularMocks'], function() { describe('App module tests', function(){ var module, $rootScope, scope, AppCtrl; beforeEach(function () { module = angular.module("MyApp"); inject(function($rootScope, $controller){ // The injector unwraps the underscores (_) from around the parameter names when matching scope = $rootScope.$new(); AppCtrl = $controller('AppCtrl', {$scope: scope}); }); }); }); }); In my app.js, I have.. var MyApp

get clicked model and add to other collection in backbone

梦想的初衷 提交于 2019-12-12 02:33:16
问题 I need to click items on ItemCollection and transfer it to CartCollection. But i can't get it to work. I need to get the model of the currentTarget clicked by the user. Any ideas? I commented out a CartCollection.add just to test it. define([ 'jquery', 'underscore', 'backbone', 'model/item_model', 'model/cart_model', 'collection/item_collection', 'collection/cart_collection', 'view/cart/cartlist_view', 'text!templates/items/itemlist.html' ],function($, _, Backbone, Item, Cart, ItemCollection,

Javascript regex to match a pattern but NOT match a regex literal (r.js optimizer and uglify issue)?

一笑奈何 提交于 2019-12-12 02:26:43
问题 I've got a Backbone application, organized into modules using Require.js. One of these modules contains a Handlebars helper, which has a method I use to pull a legal header off of all our HTML templates for each View. The header is contained in an HTML comment, so I use the following regex to strip it off: /<!--[\s\S]*?-->/g Now, when I optimize (concatenate/compile/minify) the application using r.js, I'm doing the same removal of HTML comments using the onBuildWrite() method of r.js:

Load standard javascript files with requireJS

纵饮孤独 提交于 2019-12-12 02:14:32
问题 I'm trying out requireJS in order to improve the loading of Javascript on an ASP.NET MVC app, using Knockout. I have some files defining custom ko bindings like that: (function (ko, bindings) { bindings.stopBinding = { init: function () { return { controlsDescendantBindings: false }; } }; bindings.anotherBinding = { ... }; })(ko, ko.bindingHandlers); If I try to load it as a requireJS module this way: define(['jquery', 'knockout', 'custom/knockout.bindings'], function ($, ko){ ko

requirejs - why loading module in define() works, but in require() doesn't

纵饮孤独 提交于 2019-12-12 02:14:04
问题 Code blow doesn't work, and the error msg is: Uncaught Error: Module name "text!templates/bookTemplate.html_unnormalized2" has not been loaded yet for context: _. Use require([]) define(['backbone', 'underscore', 'jquery'], function (Backbone, _, $) { var bt = require('text!templates/bookTemplate.html'); var BookView = Backbone.View.extend({ initialize: function () { this.render(); }, render: function () { var template = _.template(bt, { name: 'secret book' }); this.$el.html(template); } });

No dependencies defined when they are loaded via absolute paths

依然范特西╮ 提交于 2019-12-12 02:05:05
问题 I have some module like this: define('hello',[], function() { return { say: function(word) { console.log("Hello, "+word) }, }; }); And I'm using it like this (without any require.config) : require(["hello"], function(hello) { console.log("main",hello); hello.say("main"); }); So far, so good. But when I'm trying to require the same module with an absolute path, I've got my dependence module undefined: require(["http://example.com/js/hello.js"], function(hello) { console.log("main",hello);

requirejs anonymous dependency not defined

懵懂的女人 提交于 2019-12-12 01:59:34
问题 I have a problem with requirejs and a dependency being undefined. My setup is the following: var lib = function (){...}; define(function() { return lib; }); And the modules are define like this var mod = function (){ ... lib('para') ... }; define(["lib/lib"], function(lib) { return mod; }); In my main.js I have this require(['lib/lib'], function(lib){ lib('para').mod(); }) The Problem: Lib is available in main.js but for mod I get an error Uncaught ReferenceError: lib is not defined 回答1: So

How can I load a module with RequireJS for testing in a testing framework like Jasmine?

╄→尐↘猪︶ㄣ 提交于 2019-12-12 01:54:10
问题 I am new to JavaScript and try to test functions defined in a RequireJS Module. That means i have some code like this: define([...], function(...){ var ModuleName = Base.extend({ init: function(){ //some code }; }); } Now I want to test the function init(). I load the object from my spec.js, this works: describe("ModuleName", function(){ var mod = require(['../js/app/ModuleName.js'], function(ModuleName) {}); it("exists", function(){ expect(mod).toBeDefined(); }); }); This passes well. But