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
0 votes
1 answer
794 views

How can I access to some model in Backbone collection

I have a collection of models: city = new M.City App.citiesList = new C.CitiesList model: city App.citiesList.fetch() How can I access to the model with id=15 for example? I need something like App....
ValeriiVasin's user avatar
  • 8,698
2 votes
1 answer
3k views

How to select (highlight) text in input textbox

Hi I am using haml and coffescript to write my code. The code snippets are as follows //haml code for input box and value %input.detail_text{value: "<%= 'http://dailymus.es/#!/' + answer.user....
Zhen's user avatar
  • 12.4k
1 vote
1 answer
726 views

Differentiating back/forward navigation with backbone.js routing

I have a simple router setup here: class Router extends Backbone.Router routes: '/a': 'a' '/b': 'b' a: -> alert 'a' b: -> alert 'b' app = new Router() app.navigate '/a' Backbone....
Alex Wayne's user avatar
  • 183k
13 votes
6 answers
18k views

IDE or editor for Node.js+Express and CoffeeScript

Preferably an IDE. Integrated support for Subversion/Git is a big plus as we are a group of 6 people working. Vim/Emacs is not that popular with the other as it is very awkward and hard to get ...
kornfridge's user avatar
  • 5,182
16 votes
3 answers
10k views

Extending multiple classes in coffee-script

The documentation explain how to extend a class class Zebra extends Animal ... But how do I extend multiple classes? The following does not work class Sidebar extends Controller, EventEmitter ...
Hubro's user avatar
  • 57.8k
0 votes
1 answer
368 views

Backbone/Javascript remove element from dom

I have a page with two div classes which is fine. One is the collection the other the item. But when i want to select edit, i need to remove the item view and replace it with the edit link, this is ...
user901790's user avatar
7 votes
2 answers
4k views

Why jasmine-node doesn't find my spec files?

I have installed jasmine-node using npm. My project's directory structure are following: |-lib\ |-taxCalc.js |-spec\ |-taxCalc.spec.coffee |-taxCalc.spec.js |-src\ |-taxCalc.coffee When ...
marisks's user avatar
  • 1,822
9 votes
4 answers
6k views

How to generate global, named javascript functions in coffeescript, for Google Apps Script

I'd like to write Javascript scripts for Google Apps Script using CoffeeScript, and I'm having trouble generating functions in the expected form. Google Apps Script expects a script to contain top-...
mattbh's user avatar
  • 5,310
0 votes
2 answers
854 views

Access variable from controller within a respond_to js file

I'm using Rails 3.1 and trying to add some ajax functionality (using jquery + coffeescript). I have a respond_to block in the controller def edit @variable = 123 respond_to do |...
Dave Smylie's user avatar
  • 2,683
1 vote
2 answers
942 views

Spine JS error rendering .eco template using Hem : "Cannot read property 'length' of undefined"

Learning spine.js I completed both the tutorials no problem, seems like a great framework, but this simple little problem is driving me nuts, because I have no idea what I can do to fix it... From ...
just__matt's user avatar
3 votes
1 answer
1k views

On using mixins in a CoffeeScript game engine

I am working on a CoffeeScript game engine for Html5 canvas. I came up with the "cool" idea to utilize mixins after I checked a very neat CoffeeScript implementation. I thought, it may be a very cool ...
Preslav Rachev's user avatar
6 votes
1 answer
2k views

How can I import a javascript library in CoffeeScript?

When I am loading my page I include a javascript library that is used to create graphs with the Google api. I am handling this with CoffeeScript in the front end. According to the tutorial I am ...
topless's user avatar
  • 8,149
9 votes
5 answers
9k views

is coffeescript faster than javascript?

Javascript is everywhere and to my mind is constantly gaining importance. Most programmers would agree that while Javascript itself is ugly, its "territory" sure is impressive. With the capabilities ...
lhk's user avatar
  • 28.7k
1 vote
2 answers
102 views

Is it possible to write an anonymous squaring function in CoffeeScript?

The official site shows the following function square = (x) -> x * x Then you can do something like square(4) Is it possible to do the above in a single line using anonymous function? I'm ...
Hoa's user avatar
  • 20.3k
0 votes
1 answer
446 views

Why does my CoffeeScript program issue 'number is not a function' error?

In the program below the first two logs work fine. I'm not doing anything new in the third and final log but somehow it crashes at runtime. Where is the error in my script? I have looked it over a ...
deltanovember's user avatar
2 votes
1 answer
809 views

asynchronous map in coffeescript

Is there an elegant way to asynchronously map an object or array in coffeescript? (Or javascript.) Imagine I have some things in an object: things = x: ... y: ... z: ... ...
mainsocial's user avatar
  • 7,613
0 votes
1 answer
843 views

CoffeeScript and erb : require variable file

In my rails 3.1 App, I have 3 different javascript files for my html table. Let say, table1.js.coffee, table2 and table3. In my application.js file, I have : // = require table And in my table.js....
Mathieu Mahé's user avatar
107 votes
9 answers
27k views

Defining an array of anonymous objects in CoffeeScript

How do I define an array of anonymous objects in CoffeeScript? Is this possible at all, using the YAML syntax? I know that having an array of named objects is quite easy: items:[ item1: ...
Preslav Rachev's user avatar
2 votes
4 answers
4k views

Multiple Constructors in coffeescript

When I try to write multiple constructors in coffee script, i get this error: cannot define more than one constructor in a class. How can I do this: class Vector2 x: 0 y: 0 constructor:() -&...
Shawn Mclean's user avatar
  • 57.1k
9 votes
3 answers
8k views

error installing coffeescript on mac 10.7.2

Node and npm are both installed and up to date but keep getting this error when trying to install coffeescript. I am still new to programming so any advice would be greatly appreciated. test-macbook:~...
Anconia's user avatar
  • 3,998
16 votes
3 answers
10k views

Good IDE for node.js + coffeescript + jasmine [closed]

What good IDEs are there to develop with the combination of Jasmine, node.js and coffeescript. So far, we're considering WebStorm, but it is really hard to get started. We find very little ...
kornfridge's user avatar
  • 5,182
5 votes
2 answers
7k views

Rails 3- Render partial on an ajax call within a popup

I have a button with remote=>true that calls a popup (a jquery popup, not a real one) in the following way: $modal = $('#modal') $modal_close = $modal.find('.close') $modal_container = $('#modal-...
Tony's user avatar
  • 10.2k
6 votes
2 answers
504 views

Why does CoffeeScript require whitespace after map?

This code nums = [1..10].map (i) -> i*2 Runs Whereas this nums = [1..10].map(i) -> i*2 is broken
deltanovember's user avatar
33 votes
3 answers
24k views

ExecJS::ProgramError: SyntaxError: Reserved word "function"

In our rails rfq.js.coffee, we only have a simple js code: $(function() { $('#need_report').change(function(){ if ($(this).val() == true) { $('#report_language').hide(); } // end if ...
user938363's user avatar
  • 10.1k
1 vote
1 answer
143 views

please explain this coffeescript construct

a snippet from a sample: class Animal constructor: (@name) -> the documentation says that @name is a syntactic sugar for this.name. Where does it say that the above function also performs ...
akonsu's user avatar
  • 29.2k
0 votes
1 answer
407 views

Uncaught type error with CoffeeScript and Backbone.js

Rails app, learning CoffeeScript and Backbone.js: Uncaught TypeError: Cannot use 'in' operator to search for 'id' in easy _.extend.setbackbone.js:205 Backbone.Modelbackbone.js:142 Gamegames.js:13 (...
explainer's user avatar
  • 1,335
1 vote
2 answers
523 views

Accessing view from within ajax success() call

I have a backbone.js view which has the following ajax call: BackboneDemo.Views.Projects.ProjectView extends Backbone.View demoFunction: () -> ... ... @collection.create(...
PlankTon's user avatar
  • 12.5k
1 vote
1 answer
150 views

Comprehension over the properties of an object + callback

At first I was a little confused about what was happening with the following code: people = jim: 'Jim' james: 'James' for k, v of people setTimeout( ( -> console.log(k) ), 300 ) #OUTPUT #...
Pickels's user avatar
  • 34.3k
11 votes
5 answers
3k views

coffeescript, jade, stylus -> js, css asset manager? node.js

I work in coffeescript, jade and stylus. My application serves two different "one page apps". For these apps I serve all asset in the initial payload. I want to group, compile, and ...
fancy's user avatar
  • 50.2k
5 votes
2 answers
3k views

Why is rails using the .js.coffee extension for coffeescript files when they cannot contain javascript code anyway?

I found that to be rather misleading as I thought it suggest that such files could include a mixture of both javascript and coffeescript code. Is there something very fundamental that I am missing?
prusswan's user avatar
  • 6,976
7 votes
4 answers
587 views

Map restructuring

In clojure, I can destructure a map like this: (let [{:keys [key1 key2]} {:key1 1 :key2 2}] ...) which is similar to CoffeeScript's method: {key1, key2} = {key1: 1, key2: 2} CoffeeScript can ...
benekastah's user avatar
  • 5,691
1 vote
1 answer
552 views

Merge coffeescript into your node project?

Is setting a bunch of watchers to compile to js still the best approach in development or is there something more elegant? I'm looking for techniques or packages that handle CoffeeScript in ...
fancy's user avatar
  • 50.2k
1 vote
1 answer
209 views

Where should cake generated js files from a coffeescript node app go?

I'm using coffeescript while writing a node js app and use cake watch to compile my js files real time. That's great to be able to do that - but where should I stick those js files? Right now, I'm ...
Daniel D's user avatar
  • 3,667
2 votes
2 answers
997 views

What are the best node packages to develop javascript browser apps?

i started to use nodejs which is a great tool. I use it to developp my front end , i'm already using the coffee-script to automatically compile to javascript , and the jasmine package that allows me ...
mpm's user avatar
  • 20.2k
1 vote
1 answer
895 views

Issue attempting to run Brunch localhost with

I have installed Brunch into my working directory as well as Coffee Script. Installation went over fine. When I try to run the local server with: gorteks$ brunch watch --server I get: [Brunch]: ...
David Diliberto's user avatar
0 votes
2 answers
1k views

Writing a "batch file" to execute CoffeeScript on Node... on Mac

On Windows, I have the following .cmd file: .\node_modules\.bin\coffee .\lib\cli --html="index.htm" --whichBuild="configs/whichBuild.xml" %* That is: I call .\node_modules\.bin\coffee.cmd Telling ...
Domenic's user avatar
  • 112k
6 votes
2 answers
304 views

Handle infinite lists in CoffeeScript

In Haskell I can do this to handle an infinite list. takeWhile (<1000) [1 ..] Is there a way to this in CoffeeScript?
marknery's user avatar
  • 1,533
2 votes
2 answers
579 views

spine.js: "Uncaught Unknown record"

I use spine.js in conjunction with the Spine.Ajax Module to load stuff via JSON from the Server. I've probably run into some syncronisation problem. I have a sidebar which just binds to the refresh ...
iblue's user avatar
  • 30k
2 votes
2 answers
5k views

how to redirect to a page with jQuery/CoffeeScript

I am trying this but have an jQuery Error $(location).attr("href",'/imageblocks/'+$(el).attr('id')+'/edit/') It works perfectly on JavaScript but trigger an jQuery error with CoffeScript, i guess it'...
Lefty's user avatar
  • 395
-3 votes
1 answer
1k views

CoffeeScript functions

I was reading this smooth CoffeeScript book and it had a code confirm 'Shall we, then?', (answer) -> show answer This is supposed to get the answer from the confirm and show it / I changed the '...
coool's user avatar
  • 8,227
144 votes
4 answers
34k views

CoffeeScript, When to use fat arrow (=>) over arrow (->) and vice versa

When building a class in CoffeeScript, should all the instance method be defined using the => ("fat arrow") operator and all the static methods being defined using the -> operator?
Ali Salehi's user avatar
  • 6,979
0 votes
2 answers
832 views

How to show 3 items in an array every time I click on button

I am using the code below to show only the first 3 items in an array as default //Hides all but first 3 items in the array @$('.question_container')[3..-1].hide() Now, I want to display the next 3 ...
Zhen's user avatar
  • 12.4k
0 votes
2 answers
3k views

Coffeescript/JQuery/Rails: $.ajax - Parse error, unexpected '{'

I don't manage to get past a simple parser error for quite some time now. I found several code sample on the web and those seem to be similar - I would deeply appreciate a hint! $ -> $("....
Markus Proske's user avatar
0 votes
3 answers
3k views

coffeescript to js service

Is there a service available to compile .coffee files and serve them as plain JS files : <script src="http://coffee2js.com?url=http://gist.github.com/foo.coffee"></script> Thanks
abernier's user avatar
  • 27.6k
1 vote
1 answer
1k views

Coffeescript and jQuery TypeError

I recently had a little problem using a jquery plugin with coffeescript (within the Rails 3.1 asset pipeline, if that helps). I looked around a bit, but couldn't really figure out, why it behaves ...
Marcel Fahle's user avatar
3 votes
1 answer
521 views

How do I use jQuery to filter a table?

I'm stuck trying to implement a user-configurable filter on a table using jQuery (in coffeescript). I have annotated each row in my table with a CSS class that identifies its category and brand: <...
Stewart Johnson's user avatar
0 votes
1 answer
414 views

Spine.js Dynamic Models // Coffeescript Dynamic Class Creation

Ladies & Gentlemen, Short Version: Trying to dynamically create a Spine Model Class. Basically I get a JSON from the server telling me what the model name is and what it´s attributes are and then ...
thomas's user avatar
  • 155
-1 votes
1 answer
323 views

Variable not found in CoffeeScript

I am new to coffee scripting..This is my first script and is not working.. html head title='hello world' css: h1{ color: blue; } coffee: number = 42 opposite = true ...
coool's user avatar
  • 8,227
0 votes
2 answers
3k views

String is not a function in Coffescript

i just started to learn coffeescript and it's great, but it's tricky.. i try to translate code, that worked in javascript to coffeescript and i fail alot, in a link i posted 3 pastes js.js is ...
Umren's user avatar
  • 392
1 vote
1 answer
945 views

How to resolve circular dependencies with nested views in Backbone.js

I'm building an app using Brunch and Backbone.js that is to include nested menus. I have created a MenuItemModel and a MenuItemsCollection, both extending their corresponding Backbone-base-objects. ...
j.koch's user avatar
  • 8

1
176 177
178
179 180
195