coffeescript

How to apply backbone router for full path, not a hash

孤街浪徒 提交于 2019-12-20 09:20:09
问题 Does that possibility exist? Our site is not one page, but all js-files compressed inside of application.js , can I use backbone router for location.path parsing? I try Backbone.history.start(pushState: true) . It works for me, but is it correct? I need just initial parsing, not complicated routes and redirects via Backbone.Router . 回答1: You can just use a standard router. When you instantiate it and start the history object you can set what the root directory it should use as its base. In

Upload Progress — Request

大憨熊 提交于 2019-12-20 09:13:51
问题 I'm uploading a file using Request. req = request.post url: "http://foo.com", body: fileAsBuffer, (err, res, body) -> console.log "Uploaded!" How do I know how much data has actually been uploaded? Is there some event that I can subscribe to or is there a property of the request that I can poll? If none, what would be the best approach to upload data and know how much has been uploaded? 回答1: I needed a handle on the upload progress for yet another project of mine. What I found out is that you

What's the best way to use CoffeeScript with Django if you're developing on Windows?

╄→尐↘猪︶ㄣ 提交于 2019-12-20 08:29:39
问题 While starting to use Sass / Compass with Django couldn't be much easier regardless of platform, it has taken a bit of searching around to find the best way to use CoffeeScript with Django on a Windows development box. 回答1: Node support on Windows has greatly improved since I posted my original answer (which I will leave for historical purposes), so now it's much easier to get this working. Download and install Node using the Windows installer. You get node and npm commands added to your

Debugging CoffeeScript line-by-line

假装没事ソ 提交于 2019-12-20 08:24:04
问题 Is there a way to debug CoffeeScript line-by-line? I understand that it compiles into Javascript. But this sounds like it could make it a pain to debug. 回答1: At the moment it is quite a pain to debug CoffeeScript. Most people use lots of unit tests. There is some work being done on debugging for CoffeeScript but it is probably a while away before we'll have a really good debugger. One example is http://www.infoq.com/news/2011/08/debug-languages-on-javascript-vm 回答2: Update : there's currently

Why doesn't the fat arrow bind to this when I pipe my method definition thru an intermediary function?

血红的双手。 提交于 2019-12-20 07:26:52
问题 I have the following code that declares a method which is advised by an intermediary function before the function result is assigned to a prototype slot. class A somemethod: advise => @dosomething() Why does the fat arrow does not bind to the instance in this case? 回答1: Simple answer When an intermediary is put between the prototype slot name and function definition you break the syntactic pattern that makes the CS emit the binding code in the constructor class A foo: (paramlist) => bar: ()=>

Node.js: Document returning undefined - Mongoose

和自甴很熟 提交于 2019-12-20 07:07:15
问题 Phone.find {number : "12345678"}, (err,phone) -> phone.forEach (item, i) -> console.log item console.log item.subdomain console.log item.subdomain_id console.log item.city returns: { _id: 4e9b614e01c642c2be000002, city: 'San Francisco', country: 'US', indicative: '234', number: '12345678', subdomain_id: 4e9b532b01c642bf4a000003 } undefined undefined San Francisco Why is the item.subdomain_id returning undefined if it's in the document? Edit: I added subdomain_id to the Schema and it now works

does this promise look correct?

蓝咒 提交于 2019-12-20 06:38:30
问题 this seems like it should be delivering data to my scope, but it isn't, is there anything that directly jumps out as wrong with the below code ? angular.module('Lunch.services', []) .factory 'LunchMates', ($q, $http) -> LunchMates = getLunchMates: () -> d = $q.defer(); $http.get('/lunchers').then (response, status) -> if response.status == 200 d.resolve(response.data) return d.promise return LunchMates angular.module('Lunch.controllers', []) .controller('LunchCtrl', ($scope, LunchMates) ->

jQuery Datepicker showAnim not animating

和自甴很熟 提交于 2019-12-20 06:37:16
问题 I've tried numerous ways and scoured the internet to try and make Animations work and have drawn a blank. I have the datepicker working and date format option but not animations (I'm looking to use the 'clip' option). Here's what's in the various files: Application.js //= require jquery //= require jquery.turbolinks //= require jquery-ui/datepicker //= require jquery_ujs //= require turbolinks //= require_tree . Events.js.coffee jQuery -> $("#datepicker").datepicker( dateFormat: "DD, d MM, yy

Backbone.js: models not appearing

 ̄綄美尐妖づ 提交于 2019-12-20 06:09:29
问题 I want to display a simple list of languages. class Language extends Backbone.Model defaults: id: 1 language: 'N/A' class LanguageList extends Backbone.Collection model: Language url: '/languages' languages = new LanguageList class LanguageListView extends Backbone.View el: $ '#here' initialize: -> _.bindAll @ @render() render: -> languages.fetch() console.log languages.models list_view = new LanguageListView languages.models appears empty, although I checked that the request came in and

JS [ES5] How to assign objects with setters and getters?

浪尽此生 提交于 2019-12-20 03:29:14
问题 obj1 = Object.create({}, { property: { enumerable: true, value: 42 } }) > obj1.property = 56 > 56 > obj1.property > 42 with use strict there is an error. I want to combine multiple objects: with jQuery.extend(): new_obj = $.extend(true, objN, obj1) with ES6 Object.assign: new_obj = Object.assign({}, objN, obj1) In any case, the getter turns into a regular property, and therefore it can be changed. How to avoid it? 回答1: You can write your own function that also copies over property attributes: