underscore.js

jQuery / underscore.js templating - Compatible with IE 6+?

筅森魡賤 提交于 2019-12-06 02:16:49
So, I just learned about these recently and am about to put them into a site. Now, the question I am posing is, does this at all throw any kid of errors in IE 6+? Yes, I know IE6, what can you do.. When I say errors, I mean IE errors / warnings. Appreciate all the help as usual, thanks in advance. -Wes Firstly, yes: jQuery does work with IE6 -- it says as much on the jQuery Homepage (hover over the "Cross browser" link and you'll see a popup that says IE6+). (having said that, a lot of third-party jQuery plugins are not IE6 compatible, so be careful about that) Underscore.js I'm less certain

Angularjs use custom interpolation symbols for scope

十年热恋 提交于 2019-12-06 01:57:10
问题 I currently have an underscore.js template that I would also like to use with angular and still be able to use with underscore. I was wondering if it's possible to change the interpolation start and end symbols for a particular scope using a directive, like this: angular.directive('underscoreTemplate', function ($parse, $compile, $interpolateProvider, $interpolate) { return { restrict: "E", replace: false, link: function (scope, element, attrs) { $interpolateProvider.startSymbol("<%=")

template not loading in backbone.js ( TypeError: text is undefined )

狂风中的少年 提交于 2019-12-06 01:41:46
问题 I'm learning backbone.js and I'm pretty much in the beginning. I want to add a template through underscore template method but it's not working for me. I searched for this error but couldn't fix it myself. How can I move forward if it's not showing the template. Need some help guys. Here is the code (this code is from addyosmani's book backbone-fundamentals): <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>testing</title> </head> <body> <script src="scripts/jquery.js"></script>

IBM Worklight 6.1 - Uncaught ReferenceErrors: WLJQ is not defined, WL is not defined

倖福魔咒の 提交于 2019-12-06 00:08:42
I'm using IBM Worklight Developer Edition 6.1 installed in Eclipse Juno as my IDE and backbonejs as my main javascript framework for my project. My index.html <!doctype html> <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]--> <!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width,

How to effectively debug method chained function arguments?

风流意气都作罢 提交于 2019-12-06 00:06:14
问题 Have a look at the following code structure: myFunction( _(myArray) .filter({ keep: true }) .uniq('id') .value() ); myFunction() takes as its argument the result of some array transformation using lodash. While I like the style of the code, I find it hard to debug and end up refactoring it to have the lodash code inside another function or assign it to a variable first, then pass the variable to myFunction() . Do you know of an effective way to debug the function argument code without

Understanding the declaration of the underscore in _.js?

左心房为你撑大大i 提交于 2019-12-05 21:09:18
This is from the beginning of the annotated source of _.js . Try though I may, my JavaScript abilities are not at a high enough level to understand what's going on here. I'm hoping someone can give a real step by step explanation. I really have literally no idea what the code below does besides somehow setting up the _ for use, despite that I understand each individual expression. var _ = function(obj) { if (obj instanceof _) return obj; if (!(this instanceof _)) return new _(obj); this._wrapped = obj; }; if (typeof exports !== 'undefined') { if (typeof module !== 'undefined' && module.exports

Uncaught TypeError: Cannot read property 'localStorage' of undefined

最后都变了- 提交于 2019-12-05 19:39:24
I have the following in the backbonejs app: ////MODEL var app={}; app.ledger=Backbone.Model.extend(); ////COLLECTION app.ledgerList=Backbone.Collection.extend({ model: app.ledger, localStorage:new Store('ledgerstore') }); ////INITIATING COLLECTION app.ledgerlist=new app.ledgerList(); In one of my views i try to create a new model in the collection like this: newAttributes:function(){ return{ name:$("#ledgerName").val(), email: $("#ledgerEmail").val(), address: $("#ledgerAddress").val(), phone: $("#ledgerPhone").val() }}, saveLedger: function(){ app.ledgerlist.create(this.newAttributes()); } I

requirejs: Module name “underscore” has not been loaded yet for context [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-05 18:16:42
This question already has answers here : Trouble combining Require.js and Backbone.js/Underscore.js (3 answers) Closed 2 years ago . I always get this error when I freshly load my app, Error: Module name "underscore" has not been loaded yet for context: _. Use require([]) http://requirejs.org/docs/errors.html#notloaded ...,h){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.re... require.js (line 8) TypeError: Backbone.Model is undefined var ProjectModel = Backbone.Model.extend({ But then they are gone when I hit the refresh button on my browser. Does anyone know why?

lodash/underscore; compare two objects and remove duplicates

天涯浪子 提交于 2019-12-05 18:00:22
As you can see in the image below, I have some returned json data with three objects; each contains a clients id => data. exact_match : {104} match_4 : {104, 103} match_2 : {104, 103, 68} How can I "trim" or remove the duplicate objects based on previous ones? something like: exact_match : {104} match_4 : {103} match_2 : {68} I tried _.difference but did not work (Maybe because it is for arrays not objects?): var exact_match = data.exact_match, match_four_digits = _.difference(data.match_4, data.exact_match), match_two_digits = _.difference(data.match_2, data.exact_match, data.match_4), Any

Why can't I use Backbone.Collection as a generic collection? Is there an implementation that does this?

笑着哭i 提交于 2019-12-05 17:54:20
After I asked this question and realized that Backbone.Collection s are strictly for Backbone.Models , I'm a little disappointed. What I was hoping for: Make underscore's methods more object oriented: _.invoke(myCollection, 'method'); ==> myCollection.invoke('method'); I'll admit, minor difference, yet still it seems nice. What problems will I run into if I use Backbone.Collection for non- Backbone.Models ? Are there any existing implementations, or a simple way to make a generic underscore collection class? While you can't use a Backbone Collection without using models, I came up with a