underscore.js

router.js Function not executed

被刻印的时光 ゝ 提交于 2019-12-29 09:36:47
问题 // Filename: router.js console.log('TEST ROUTE'); define([ 'jquery', 'underscore', 'backbone', 'views/jobs/list' ], function($, _, Backbone, JobListView){ var AppRouter = Backbone.Router.extend({ routes: { // Define some URL routes '/dalo/jobs': 'showJobs', // Default '*actions': 'defaultAction' } }); var initialize = function(){ var app_router = new AppRouter; app_router.on('route:showJobs', function(){ // Call render on the module we loaded in via the dependency array // 'views/jobs/list'

pure css slider

你离开我真会死。 提交于 2019-12-29 07:52:15
问题 I'm trying to get one pure css slider (http://jsfiddle.net/trN4p/1/) to operate within another pure css slider on the same document/page using :target for navigation with independent control for each slider. Here is an example of the problem: http://jsfiddle.net/J6htH/4/ I want the inside (CHILD) slider to work independently of and alongside (w/out conflict) the outside (PARENT) slider. I was wondering if there is a way to separate the two sliders so that their list items (and hash tags)

In the Node.js REPL, why does this happen?

戏子无情 提交于 2019-12-29 07:42:15
问题 So I was playing around with the Node.js REPL and the Underscore library when I noticed something very strange. If I require("underscore") , the variable _ is set globally (obviously). Then when I attempt to run a simple command like console.log(_.isEmpty) it prints [Function] (again, obviously). However, upon running console.log(_) right after, it prints [Function] because the variable _ was set to _.isEmpty . Why does this do this? If I run the same code from a js file this doesn't happen.

In the Node.js REPL, why does this happen?

本秂侑毒 提交于 2019-12-29 07:41:30
问题 So I was playing around with the Node.js REPL and the Underscore library when I noticed something very strange. If I require("underscore") , the variable _ is set globally (obviously). Then when I attempt to run a simple command like console.log(_.isEmpty) it prints [Function] (again, obviously). However, upon running console.log(_) right after, it prints [Function] because the variable _ was set to _.isEmpty . Why does this do this? If I run the same code from a js file this doesn't happen.

Is there any way to rename js object keys using underscore.js

瘦欲@ 提交于 2019-12-28 11:45:11
问题 I need to convert a js object to another object for passing onto a server post where the names of the keys differ for example var a = { name : "Foo", amount: 55, reported : false, ... <snip/> ... date : "10/01/2001" } needs to turn into a = { id : "Foo", total : 55, updated: false, ... <snip/> ... issued : "10/01/2001" } where I have lookup obj available for mapping all the keys var serverKeyMap = { name : "id", amount : "total", reported : "updated", ... date : "issue" } Is there a function

Is there any way to rename js object keys using underscore.js

筅森魡賤 提交于 2019-12-28 11:44:05
问题 I need to convert a js object to another object for passing onto a server post where the names of the keys differ for example var a = { name : "Foo", amount: 55, reported : false, ... <snip/> ... date : "10/01/2001" } needs to turn into a = { id : "Foo", total : 55, updated: false, ... <snip/> ... issued : "10/01/2001" } where I have lookup obj available for mapping all the keys var serverKeyMap = { name : "id", amount : "total", reported : "updated", ... date : "issue" } Is there a function

What does _.debounce do?

喜夏-厌秋 提交于 2019-12-28 01:49:15
问题 A project I've been working on uses _.debounce(). The Underscore JS documentation for debounce reads as follows: debounce _.debounce(function, wait, [immediate]) Creates and returns a new debounced version of the passed function that will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked. This obviously assumes that anyone who wants to know what debounce() does, already knows what 'debounce' means. What does debounce actually do? 回答1:

Summarize array values, underscore

自闭症网瘾萝莉.ら 提交于 2019-12-25 18:38:08
问题 Got this array: var arr = [ { series: [ { "name": 2014, "data": [19, 17, 15, 12, 10, 10, 12, 10, 11, 14, 14, 18] }, { "name": 2015, "data": [18, 17, 16, 12, 10, 7, 6, 8, 8, 11, 15, 30] }, ] }, { series: [ { "name": 2014, "data": [32, 17, 15, 12, 33 10, 33, 10, 11, 14, 14, 18] }, { "name": 2015, "data": [45, 10, 12, 55, 77, 7, 6, 8, 8, 11, 33, 30] }, ] }, ] I need to create a function that returns a summrized series: var series = [ { year: '2014', data: [51, 34....], }, { year: '2015', data:

Move a particular value object in array to end

有些话、适合烂在心里 提交于 2019-12-25 18:16:52
问题 I'm trying to find a way to move an object to the end of the array I have this array of objects: [ {"id":"4","name":"Boaz"}, {"id":"2","name":"Shareen"}, {"id":"3","name":"Simon"}, {"id":"1","name":"Miriam"} ] I want to move the whole set {"id":"3","name":"Simon"} to the end of it all. I have solution for this here. But my problem is every time that particular object is not coming in second position is there a way to check the object of id=3 and shift that to end using underscoreJS 回答1: You

lodash Mapping Keys from one object with values in array of objects

偶尔善良 提交于 2019-12-25 17:45:51
问题 I have the following object: var kmap={ key1:"useless", key2:"useless", key3:"useless" }; I need to map its keys with values of this array of Objects: var incoming=[ {value:"asd"}, {value:"qwe"}, {value:"zxc"} ]; Result: { key1:"asd", key2:"qwe", key3:"zxc", } Here's how I'm doing it right now: var result={}; var keys=Object.keys(kmap); for(var i=0;i<incoming.length;i++) { result[keys[i]]=incoming[i].value; } How do I do it using lodash or underscore . Built-in method would be even better,