coffeescript

Coffeescript, Backbone and load order

浪子不回头ぞ 提交于 2020-01-03 18:59:32
问题 Consider this Coffeescript class, in an app where each class lives in its own file. class Manager extends Person title: titles["manager"] If that file is loaded before the "titles" object, an error generated. I'm assuming this is because of Coffeescripts safety wrapper which is performing ".call(this)" when this file is first loaded? Otherwise, if I were to delay running any code until after the entire page had fully loaded ($(document.ready()), I could be sure that all the javascript files

Dependent Dropdown Contents with jquery-select2

限于喜欢 提交于 2020-01-03 17:06:33
问题 I have a Rails 4 app where I'm using Jquery-select2 for my dropdown lists. I have two dropdowns where I want the selection in the first do dictate what the user can select in the second. Sort of like selecting a country and being given a list of states for that country. In my application I have Demographic and Response models. When someone selects a Demographic I want to populate the Responses list with the appropriate items for that Demographic. I had this working before I started using

CoffeeScript: How to return a array From class?

心已入冬 提交于 2020-01-03 16:44:31
问题 What is wrong in this class in CoffeeScript ?? @module "Euclidean2D", -> class @Point constructor: (x,y) -> return if Float32Array? then Float32Array([ x, y ]) else Array(x,y) I want it to behave like: p = new Point(1.0,2.0); p[0] == 1.0 p[1] == 2.0 But testing with Jasmine I get "Expected undefined to equal 1." describe "Point", -> beforeEach -> @point = new Euclidean2D.Point(1.0,2.0) it "extracts values", -> (expect @point[0]).toEqual 1.0 (expect @point[1]).toEqual 2.0 Is there an error in

Java library that converts coffeescript to javascript or compiled java executable?

大兔子大兔子 提交于 2020-01-03 16:39:46
问题 I would like to embed javascript into a java application but given coffeescript cleans up some of the superfluous syntax of javascript it would be great to support execution of coffee script in a java environment. I couldnt find any links and am asking here just incase someone knows of a translator or compiler. 回答1: if I understand you right, JCoffeescript would fit what you're after. 回答2: The wro4j project (which bundles a lot of HTML/JS/CSS processing steps for a Java toolchain, including

In meteor 0.6.4.1/coffeescript, how does variable visibility work?

牧云@^-^@ 提交于 2020-01-03 08:22:18
问题 I'm new to meteor and coffeescript. I'm using the file layout suggested in the Unofficial Meteor FAQ. In file collections/C.coffee, I have C = new Meteor.Collection 'C' console.log "C: #{C}" In file server/main.coffee, I have C.insert {test: 'test'} When I start meteor, I see on the console: C: [object Object] ReferenceError: C is not defined at app/server/main.coffee.js:5:1 at /home/xxx/yyy/.meteor/local/build/server/server.js:298:12 How do I make C available in files outside of collections

Unique array comprehension

谁都会走 提交于 2020-01-03 05:43:05
问题 I have the following array in CoffeeScript: electric_mayhem = [ { name: "Doctor Teeth", instrument: "piano" }, { name: "Janice", instrument: "piano" }, { name: "Sgt. Floyd Pepper", instrument: "bass" }, { name: "Zoot", instrument: "sax" }, { name: "Lips", instrument: "bass" }, { name: "Animal", instrument: "drums" } ] My goal is to get all instrument names from this array. Expected result: ['piano', 'bass', 'sax', 'drums'] My first solution based on this: names = (muppet.instrument for muppet

AngularJS POSTs empty requests?

假装没事ソ 提交于 2020-01-02 15:41:06
问题 I'm a newbie in AngularJS and I've faced an issue when I try to make a POST request with AngularJS and it POSTs no parameters with it. I use Sinatra as a RESTful interface. That's how my Sinatra backend looks: post '/layer/:layer_id' do @layer = PageLayer.where(id: params[:layer_id]).first @layer.content = params[:content] @layer.save end If try to POST with Postman chrome extension - it works! Sinatra saves the content properly. So I'm sure that the backend works as it should. That's how my

AngularJS POSTs empty requests?

天大地大妈咪最大 提交于 2020-01-02 15:39:32
问题 I'm a newbie in AngularJS and I've faced an issue when I try to make a POST request with AngularJS and it POSTs no parameters with it. I use Sinatra as a RESTful interface. That's how my Sinatra backend looks: post '/layer/:layer_id' do @layer = PageLayer.where(id: params[:layer_id]).first @layer.content = params[:content] @layer.save end If try to POST with Postman chrome extension - it works! Sinatra saves the content properly. So I'm sure that the backend works as it should. That's how my

AngularJS POSTs empty requests?

十年热恋 提交于 2020-01-02 15:39:17
问题 I'm a newbie in AngularJS and I've faced an issue when I try to make a POST request with AngularJS and it POSTs no parameters with it. I use Sinatra as a RESTful interface. That's how my Sinatra backend looks: post '/layer/:layer_id' do @layer = PageLayer.where(id: params[:layer_id]).first @layer.content = params[:content] @layer.save end If try to POST with Postman chrome extension - it works! Sinatra saves the content properly. So I'm sure that the backend works as it should. That's how my

Check if user is blocking 3rd party domain

痞子三分冷 提交于 2020-01-02 05:56:11
问题 I have run into an issue where a lot of our support calls are about our images not loading because the user is blocking amazon s3 or a similar 3rd party service. I use 3rd party services for hosting images, video, and some javascript. Is there a way to detect through javascript if a client is blocking a domain so that we display a message instead of having the user contact support? $.ajax 'http://aws.amazon.com/s3/', type: 'GET', dataType: 'html' complete: (e, xhr, settings) -> if e.status ==