coffeescript

Is it possible to compile Coffeescript code in script tags in html files? [duplicate]

可紊 提交于 2020-01-01 04:57:05
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Is there a way to send CoffeeScript to the client's browser and have it compiled to JavaScript there? Is there a simple way to compile Coffeescript that is inside <script> tags inside html, or do you usually have all Coffeescript in separate files? 回答1: Responding to dvcolgan's clarifying comment: So, you want to have an HTML file on the server with inline CoffeeScript that gets served as HTML with inline

how to dynamically add observer methods to an Ember.js object

心已入冬 提交于 2020-01-01 04:56:27
问题 So i am trying to dynamically add these observer methods to a Ember.js object holderStandoutCheckedChanged: (-> if @get("controller.parent.isLoaded") @get("controller").toggleParentStandout(@get("standoutHolderChecked")) ).observes("standoutHolderChecked") holderPaddingCheckedChanged: (-> if @get("controller.parent.isLoaded") @get("controller").toggleParentPadding(@get("holderPaddingChecked")) ).observes("holderPaddingChecked") holderMarginCheckedChanged: (-> if @get("controller.parent

MobileSafari won't send back Cookies set with CORS

爱⌒轻易说出口 提交于 2020-01-01 02:33:26
问题 I have a page loading up in MobileSafari which communicated with another server via CORS. In desktop browsers (tested Chrome and Safari), I am able to log in, get a session cookie, and have that session cookie be sent back for subsequent requests so that I may be authenticated with all API calls. However, when I login via Mobile Safari, the cookie does not get sent back on subsequent requests. I'm using Charles Proxy to spy on what's going on, and it tells me: POST https://myremoteserver.com

Can I use CoffeeScript in the views executed on render.js?

微笑、不失礼 提交于 2020-01-01 02:17:08
问题 What do I need to do so that I can use CoffeeScript in the Rails JS views? For example: def index format.js { render :layout => false } end What would I need to do in order for Rails to use index.js.coffee ? 回答1: It's not yet supported in 3.1. You will need to use Coffeebeans. Update: It is now supported in rails 3.2 回答2: Johnny's answer is correct. If you look at the pull request linked to from the CoffeeBeans page, you have dhh saying Once we have a fast, clean implementation, it's welcome

Is there a Coffeescript for Java? In other words X gets compiled to Java [closed]

两盒软妹~` 提交于 2020-01-01 01:30:50
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . Is there a language that gets compiled to Java code (not Byte code but Java .. so no Groovy, Scala, Jython, JRuby etc.)? In other words is there a CoffeeScript for Java? One of the major flaws I have against Java is that its so damn verbose and that it doesn't have multiple inheritance. It seems reasonably that

Method chaining with function arguments

岁酱吖の 提交于 2019-12-31 08:10:49
问题 What's the best way to chain methods in CoffeeScript? For example, if I have this JavaScript how could I write it in CoffeeScript? var req = $.get('foo.htm') .success(function( response ){ // do something // ... }) .error(function(){ // do something // ... }); 回答1: Using the latest CoffeeScript, the following: req = $.get 'foo.html' .success (response) -> do_something() .error (response) -> do_something() ...compiles to: var req; req = $.get('foo.html').success(function(response) { return do

Lexical scoping in a for loop enclosing a promise?

南笙酒味 提交于 2019-12-31 05:27:10
问题 I have an ids object, which maps id strings to product objects. for id of ids product = ids[id] console.log product # Prints out something different each loop. :) Product.create(product).then -> console.log product # Only prints out the last id each loop. :( I'm using a library for database interactions, which exposes promises (indicated by the then function above). I'm trying to print out the product variable inside the then function, but I only seem to be getting the last id in ids , so it

Bloated JS from Coffeescript which wants to return everything

一笑奈何 提交于 2019-12-31 05:07:08
问题 I've got this Coffeescript here: brew = (args...) => for e in args alert e null brew('fo', 're', 'eo'); I wish I didn't need to put null there to get it to work, but alas, that compiles to this: brew = function() { var args, e, _i, _len, _results; args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; _results = []; for (_i = 0, _len = args.length; _i < _len; _i++) { e = args[_i]; alert(e); _results.push(null); } return _results; }; brew('fo', 're', 'eo'); But now I have 3

JavaScript setInterval not being properly bound to correct closure

寵の児 提交于 2019-12-31 04:53:21
问题 Problem Hi people, I'm reasonably new to JavaScript and I come from the very object-oriented world of Python and Java, that's my disclaimer. There are two chunks of code below, alternative implementations, one in JavaScript, one in Coffeescript. I am trying to run them on the server in a Meteor.js application. The problem I am experiencing is when calling the function "setInterval" using the bound-method "this.printSomething" as my callback, once that callback is executed, it loses scope with

Is it necessary to clearTimeout inside a recursively invoked timer?

眉间皱痕 提交于 2019-12-31 04:29:27
问题 Is it necessary to call clearTimeout() inside a recursively invoked function in Coffeescript? My concern is whether not calling clearTimeout() will possibly cause some sort of memory leak over time if this function is run many many times per second. My thinking is the JS garbage collector handles this, but want to double check. A contrived example from a websockets/socket.io implementation I'm working on: socket.on 'dataReceived', => @_recursive_fn() _recursive_fn: -> @timer = setTimeout (=>