coffeescript

JQuery doesn`t fire/work with my Rails 3.2 project

a 夏天 提交于 2020-01-17 04:02:06
问题 As in the title, I`ve made sure all needed JS files are included in the meta tags, included the jquery-rails/coffee-rails gem, linked to a external one just in case. This is a modified script from Ryan Bates tutorial on Stripe, from what I understand it`s suppose to fire up by detecting the submit action from the form. Since I'm not that familiar with JS or CoffeeScript, I can't really pin point what's the problem here. Would appreciate any help I can get. The donations.js file: jQuery ->

How to escape while rendering a js.coffee file in response to an action

∥☆過路亽.° 提交于 2020-01-17 00:41:32
问题 I have a controller action that responds with a .js.coffee file, which is supposed to be supported in my version of Rails 3.2.12. The problem is that something in the parsing is allowing user provided data to cause the javascript to fail. I've simplified the example like this: action.js.coffee file: $('my_container').append("<%= j render(:partial => 'my_partial') %>") my_partial.html.erb file contains just one line that should NOT be interpolated: "#{this should not be evaluated}" The

Extending an Array properly, keeping the instance of subclass

不想你离开。 提交于 2020-01-17 00:27:09
问题 I've written a class trying to extend the native Javascript Array class with a custom class, let's call it MyClass . This is basically what it looks like: class MyClass extends Array constructor: (obj) -> @push.apply @, obj first: -> @slice 0, 1 Instantiating the class is no problem. Running this in the console: var myInstance = new MyClass(["1", "2"]) > ["1", "2"] myInstance instanceof MyClass > true myInstance instanceof Array > true works as exptected. The problem is that if I run:

jqPlot, plot date on xaxis and time on yaxis

北城以北 提交于 2020-01-16 19:38:07
问题 I'm trying to plot using jqPlot the amount of time it takes for someone to complete something. On the xaxis I have the dates displaying correctly. However, on the yaxis I want to show the hour, minutes, seconds. No matter what I try it doesn't show correctly. The screen capture belows shows the ticks mapping on the yaxis. Here's the CoffeeScript... $.jqplot( "elemid" [["2013-02-01 01:30:28 AM", 97640000],["2013-02-01 01:31:38 AM", 166270000]] axes: xaxis: min: data.XAxisMin max: data.XAxisMax

Is there a way to make Hubot reply to all messages that are not existing commands?

岁酱吖の 提交于 2020-01-16 04:54:20
问题 I'm giving Hubot a first try, and I'm making a dialog script for basic conversation. I have completed quite a few possibilities (I have a lot of questions and keywords working,) but when the user asks or says something Hubot doesn't recognize, it's complete silence. I want to add a default set of answers for Hubot when it can't find an existing command or words (vague replies like " That's interesting " or " Tell me more ".) Is there a way to do this via script? Something like: robot.respond

CoffeeScript, Node.js, MongoDB and JasperReports, is it possible?

依然范特西╮ 提交于 2020-01-15 06:10:23
问题 I just realized a JSF (web JavaScript application) that connect to a MongoDB database and generate a report (PDF) thanks to JasperReports Library (so with a .java file). Is it possible to do the same thing with a web application in CoffeeScript and Node.js? I am really new to this, so I don't know where to start. For example : Is it possible to run a .java thanks to Node.js or CoffeeScript? 回答1: JSF is actually a JavaServer Faces application, not a JavaScript application. JavaScript (which

Unexpected token ILLEGAL .. somewhere

谁说胖子不能爱 提交于 2020-01-15 03:28:06
问题 addToBasket = (id, qty) -> if $.cookie('basket')? # Basket exists basket = $.parseJSON($.cookie('basket')) basket.push( { 'id': id, 'qty': qty } ) $.cookie('basket', JSON.stringify(basket)) else # Basket doesn't exist alert 'Creating basket' basket = JSON.parse([{'id': id, 'qty': qty}]) $.cookie('basket', JSON.stringify(basket)) I'm tearing my hair out; I cannot get the (compiled equivalent) function to run, always getting the illegal token error. I've checked for rogue, invisible characters

Adding a function call on the end of function in coffeescript

牧云@^-^@ 提交于 2020-01-13 19:00:55
问题 Any ideas on how to write this as coffeescript? Person = Ember.Object.extend({ // these will be supplied by `create` firstName: null, lastName: null, fullName: function() { var firstName = this.get('firstName'); var lastName = this.get('lastName'); return firstName + ' ' + lastName; }.property('firstName', 'lastName') }); I'm particularly interested in the }.property part of the code. I can't figure out how to write this in coffeescript. 回答1: personally, i like braces around my functions:

Different SASS/Coffeescript Variable Values Based on Build

我是研究僧i 提交于 2020-01-13 17:59:52
问题 I am trying to create a build system for a front-end framework that will create different paths in SASS (and possibly Coffeescript) based on where I am deploying to. So for example, I might have an image file I am referencing in my SASS locally in ../images/image.png , and this works fine in my local environment. However, my client has a very locked down environment that has to be done in a different way (getting their images from a CDN). So their image path might look like ~Some_service_call

Different SASS/Coffeescript Variable Values Based on Build

岁酱吖の 提交于 2020-01-13 17:58:02
问题 I am trying to create a build system for a front-end framework that will create different paths in SASS (and possibly Coffeescript) based on where I am deploying to. So for example, I might have an image file I am referencing in my SASS locally in ../images/image.png , and this works fine in my local environment. However, my client has a very locked down environment that has to be done in a different way (getting their images from a CDN). So their image path might look like ~Some_service_call