Questions tagged [coffeescript]

A language that transpiles to JavaScript. Use this tag for questions about programming with the CoffeeScript language.

coffeescript
Filter by
Sorted by
Tagged with
1 vote
1 answer
2k views

Qtip2 ToolTip Not Positioning

I have this code running - $(".imgClass").each( (elem,value)-> imgSrc = $(value).attr("src") $(value).qtip({ content: "<img src=" + imgSrc + ">" position:{ ...
praks5432's user avatar
  • 7,514
1 vote
3 answers
1k views

How to enable coffeescript support in couchdb?

I am building couchdb from source using: https://github.com/iriscouch/build-couchdb/ How do I enable coffeescript as a query language? This option appears on iriscouch's cloud server.
Mike McKay's user avatar
  • 2,516
0 votes
2 answers
1k views

Call a function inside Ajax

I'm having a problem, I can't make a loop inside this code: class ProductsPager constructor: -> this.waitformsg() waitformsg: => alert 'begin' $.ajax ...
sidney's user avatar
  • 2,714
0 votes
1 answer
196 views

Backbone, How to memorize search results?

In my Backbone Application, on search results page I have link to #show action. This show action will show specified model. -search results URI /search -specified model URI /:modelName/:viewName/:...
nothing-special-here's user avatar
1 vote
2 answers
207 views

How to reduce repeated code in Backbone Router

In my routers initialize methods have the same code (the code is repeated 3 times!). I got 3 routers, so if I want to refactor code (change name etc) I will have to jump to 3 separate files and apply ...
nothing-special-here's user avatar
10 votes
2 answers
3k views

CoffeeScript: Accessing outer class objects from inner class instance

If there any way to access outer class fields from inner class instance, EXCEPT passing outer class instance to inner class constructor? To be more specific, I have a simple example: class Test ...
Mariya Davydova's user avatar
2 votes
1 answer
1k views

Regular Expression with or without /g (CoffeeScript/JavaScript)

Why if I add /g to lineRoute parseRoute function just return only one occurrence? pkt = "Record-Route: <sip:10.1.20.40;lr;r2=on>\r\nRecord-Route: <sip:10.1.20.40:80;transport=ws;r2=on;lr=on&...
pamojarpan's user avatar
1 vote
1 answer
181 views

Advanced routing and single object definition?

I'm trying to simplify routes. What I have now still requires a reference inside the class that extends router, but since I'm using eval to instantiate references, every route method is the same. ...
user avatar
0 votes
3 answers
976 views

How to update CompositeView after model.fetch() returns when called from collection.parse override?

Example: http://franklovecchio-playback.herokuapp.com/?log=true Full code: https://github.com/franklovecchio/playback You'll see the "undefined" attributes come through on the error: Uncaught ...
user avatar
1 vote
1 answer
457 views

Rails 3 save model and redirect using coffeescript

I have user class (using devise) and my User class has email subscriptions class User < ActiveRecord::Base ... has_one :email_sub, :class_name => "Subscriptions::EmailSub", :dependent => ...
hershey's user avatar
  • 475
3 votes
3 answers
8k views

Sublime Text build: cannot find the file specified

I've installed the CoffeeScript plugin via Package Control. When I try to build test.coffee it gives me this: [Error 2] The system cannot find the file specified [cmd: [u'cake', u'sbuild']] [dir: C:...
chenglou's user avatar
  • 3,640
2 votes
2 answers
2k views

Merge javascript with nodejs

I'm totally new to all the node shenanigans and don't quite know the best solution for the issue I have, maybe someone can point me towards the best solution towards it. I have a setup with the ...
August Bjornberg's user avatar
0 votes
2 answers
436 views

Unable to modify Coffeescript's global variables in a JQuery listener

Today I was migrating some of my javascript code into coffeescript and got stuck in something really silly but even though I didn't know how to make it work. I wanted to update the value of a global ...
omrsin's user avatar
  • 568
1 vote
1 answer
2k views

Backbone is undefined

Any instance of Backbone doesn't work, my console says it's undefined... As of now it says: Uncaught TypeError: Cannot call method 'start' of undefined Which correlates to this line: Backbone....
Danny's user avatar
  • 993
3 votes
1 answer
136 views

How do I check if focus has switched to a new element after another has blurred using jQuery?

I have a text input on my page. When it receives focus, a select box appears underneath it. When it loses focus, I want the select box to disappear unless the focus has shifted to the select box. ...
brad's user avatar
  • 9,693
0 votes
0 answers
281 views

Jquery Data Dropdown

so I filled a dropdown programatically like this - optionStringToAppend = "<option id=" + searchTime + ">"+ pastResult.searchDate+ "," + purpose + "</option>" $("#...
praks5432's user avatar
  • 7,514
2 votes
1 answer
7k views

Setting global res.local variables on each request in express.js

Basically I want to build a site wide navigation bar that contains links as specified in the local variables in express.js So I build my list of links I want to include on a page: class ...
Msencenb's user avatar
  • 5,104
1 vote
1 answer
2k views

AngularJS service with promises

I have an AngularJS service which does the following: It attempts to read user data from Lawnchair (localStorage abstraction with fallbacks). If user data is not in Lawnchair, the service calls a ...
Cork's user avatar
  • 722
3 votes
3 answers
4k views

How to internationalize values in coffee script

Below code is what I have in one of coffeescript files in rails application. I'm struggling to add i18n support for string values like "Select Account First" and "Select One". In regular javascript ...
Srini K's user avatar
  • 3,355
1 vote
2 answers
1k views

Node.js scope error

I'm getting the following error : /Users/nblavoie/Desktop/HotPie/HotPie/apps/authentication/routes.coffee:6 app.get('/login', function(req, res) { ^ ReferenceError: app is not defined at ...
user avatar
1 vote
1 answer
2k views

$(this) throwing TypeError: $ is not a function in Coffeescript, Rails 3.2

This is driving me absolutely crazy. So each time I use $(this) inside a jQuery Event, I get TypeError: $ is not a function. Here is a sample of the code I am using: $ -> $(".some-element")....
tagCincy's user avatar
  • 1,599
1 vote
1 answer
518 views

Backbone - Display one model rather than loop through a collection - Written in CoffeeScript

I'm new to Backbone + new to CoffeeScript. I have a collection which retrieves data (properties) from a URL. In my homeView I append this data to a template and loop through it: <ul> <% ...
Danny's user avatar
  • 993
1 vote
2 answers
594 views

Passing an arbitrary object to Coffeescript's anonymous function

When I run the following Coffeescript code: @sum = (x, y) -> x + y I get this compiled Javascript: (function() { this.sum = function(x, y) { return x + y; }; }).call(this); Is ...
Amberlamps's user avatar
1 vote
1 answer
338 views

not able to save the state in cookie

I have a simple use case where I change the background color of the li element when the user selects a particular tab. What I want is the state of the background color is maintained even if the page ...
Dev R's user avatar
  • 1,902
1 vote
1 answer
311 views

How can I get Jasmine in CoffeeScript to test for exceptions?

I have this code: class root.Goal constructor: (@name, @size) -> if @size <= 0 then throw new Error "Goal must be larger than 0 size" Tested by this Jasmine-CoffeeScript test: ...
Doug Knesek's user avatar
  • 6,637
15 votes
5 answers
15k views

Upload Progress — Request

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 ...
Gautham Badhrinathan's user avatar
1 vote
1 answer
558 views

Edit Keyboard Shortcuts in Aptana's Eclipse Plugin (w.r.t. coffeescript)

I recently installed the Aptana plugin for Eclipse, to do some Coffeescript development, and I'm loving it, but there's one annoyance that I can't seem to solve. The Shift+Enter shortcut used to be "...
Dylan's user avatar
  • 13.7k
0 votes
2 answers
2k views

An array of infoWindow in Google maps api

I looked for error and I couldn't find it. Any google maps infoWindow always shows the same information for some reason. Here is a coffeescript code infowindow = new google.maps.InfoWindow() for ...
Alexandre's user avatar
  • 13.2k
0 votes
2 answers
284 views

Checkbox button works only first time

i have an iphonestyle checkbox button made with a gem (ios-checkboxes) . I want through this button to show only some table rows(the completed/not completed specifications), depending on the button ...
vladCovaliov's user avatar
  • 4,383
8 votes
2 answers
4k views

Does CoffeeScript support interpolation in single quotation string?

I come to this question: f = (param) -> console.info '#{param}' f(1) The outcome is #{param} When I enclose the string with double quotation marks, this just print 1. I have also tested ...
Chao Zhang's user avatar
  • 1,494
0 votes
1 answer
6k views

Why did I failed to connect to websocket?

The code of Node server with ws module: show = console.log WS = require('ws').Server wss = new WS port: 8080 wss.on 'connection', (ws) -> show 'a connection' ws.on 'message', (message) -> ...
jiyinyiyong's user avatar
  • 4,644
1 vote
2 answers
1k views

Coffeescript Classes not returning last statement of function

I have been using coffeescript classes, and as far as I was aware, functions should always return the last statement automatically. I am finding however, that functions defined in the constructor ...
Billy Moon's user avatar
  • 58.1k
3 votes
1 answer
70 views

Coffeescript renders differently between 1.1.1 and 1.3.3

CoffeeScript Source return sprite: myFunc width: 79 height: 66 throw: from: {} last: {} Compiled With CoffeeScript 1.1.1 return { sprite: myFunc({ width: 79, height: 66 }), "...
Billy Moon's user avatar
  • 58.1k
2 votes
3 answers
2k views

CoffeeScript with jQuery, jQuery ($), and jQuery

In CoffeeScript with jQuery, is there any difference for following statements? jQuery ($) -> jQuery -> $ - >
angelokh's user avatar
  • 9,328
20 votes
5 answers
11k views

Getting the last element of an array in CoffeeScript

Is there a quick (short, character wise) way to get the last element of an array (assuming the array is non-empty)? I usually do: last = array[array.length-1] or last = array[-1..][0]
Lchi's user avatar
  • 426
4 votes
2 answers
6k views

jQuery UI autocomplete field not submitting when pressing enter

I'm following the Railscast on this topic, and although the autocomplete feature works, I am unable to get it to submit the form when the user selects an item and presses enter. I have this (...
A4J's user avatar
  • 889
0 votes
3 answers
197 views

Coffeescript Syntax: Structure is wrong

I simplified my code to show the problem. When I use this Coffeescript snippet: $("<div>") .text "hi" .appendTo "body" I expect it to compile like this: $("<div>").text("hi").appendTo("...
Jonny Burger's user avatar
3 votes
2 answers
3k views

How can I localise colorbox?

I installed Colorbox in my ROR application. But I need localisation. In the script i have: file images.js.coffee $(document).ready -> $(".group1").colorbox({rel:'group1', transition:"...
user1466717's user avatar
5 votes
2 answers
7k views

Mongoose error handling in one place

I found in mongoose docs that I can handle errors generally, that I want. So you can do like: Product.on('error', handleError); But what is the signature of this handleError method? I want something ...
zishe's user avatar
  • 10.7k
2 votes
1 answer
234 views

Vim, coffeescript and windows (sadly)

What is the best way of getting coffeescript to compile into javascript when using VIM on windows?
dagda1's user avatar
  • 27.9k
0 votes
1 answer
157 views

Backbone + JQuery Plugin won't work (Written in CoffeeScript)

Ok, I have a simple JQuery plugin that when applied to a div will neatly load all the images within that div using a preloader image. This works fine. However, in Backbone i'm appending data from ...
Danny's user avatar
  • 993
0 votes
1 answer
120 views

global references b/t templates and views

When dealing with specific events bound to a single dom element, I'd like a way to be able to make it apparent that the element in question has events...without looking at the javascript (along with ...
user avatar
2 votes
1 answer
3k views

Backbone, Coffeescript - passing function as a callback in AJAX

In my Backbone View, I have two methods, one does a simple AJAX call, and the other is the callback function I want to run. I want to call the AJAX method with the callback function as its parameter. ...
ericbae's user avatar
  • 9,614
2 votes
2 answers
3k views

coffeescript assignment

I have a question about this code: getContent: (index) -> content = @get('content') element = content.objectAt(index) if element? [type, clientId] = element store = @get('store') ...
dagda1's user avatar
  • 27.9k
3 votes
2 answers
2k views

How can I use coffee script in a Django project?

I'm a new developer on Django and I want to use some CoffeeScript in my dummy project. However, documentation about this topic isn't good and I want to know from the experts which is the best option. ...
Dagosi's user avatar
  • 948
0 votes
1 answer
377 views

Is it possible to share HAML templates between Coffeescript (Backbone.js) and Rails 3.2?

Is this possible? I know people use mustache to share templates, but can you use HAML? I would prefer pre compilation.
DevDevDev's user avatar
  • 5,147
0 votes
2 answers
89 views

How to write this simple javascript code in CoffeeScript?

I want this code in javascript: beforeNode = children[ children.length -1 ] With this fragment of code in coffeecript: beforeNode = children[ children.length -1 ] coffescript generate: ...
angelcervera's user avatar
  • 3,883
0 votes
1 answer
94 views

JavaScript prototype is not copied [closed]

For some reason, my classes written in CoffeeScript do not copy the prototype. Here's the exact code I'm using: module.exports = class ListQueue constructor: -> @queue = [] @queueIds =[]...
user avatar
0 votes
0 answers
177 views

Searching and finding or creating fields with partials and Ajax in Rails

Say I'm creating a book under an author, so I must pick up an existing author or create one. Well, I thought I could just have a search field; through CoffeeScript I'd have an $.ajax() returning a ...
Vitor Ussui's user avatar
-4 votes
1 answer
2k views

object is not defined error when running Jasmine tests on CoffeeScript files

I've been learning coffeescript, and as an exercise in learning it I've decided to TDD Conway's Game of Life. The first test I've chosen is to create a Cell and see if it's dead or alive. To that ...
George Stocker's user avatar

1
156 157
158
159 160
195