coffeescript

Casperjs - trying to run casper script from command line doesn't output correctly

人盡茶涼 提交于 2020-01-06 08:16:19
问题 I'm brand new to casperjs, and in the process of trying to run my first casper script from the command line (using $ casperjs sample.js ), I received this output: Casper CLI passed args: [] Casper CLI passed options: { "casper-path": "/usr/local/Cellar/casperjs/1.1-beta2/libexec", "cli": true } Instead of the predicted output of: CasperJS, a navigation scripting and testing utility for PhantomJS PhantomJS: Headless WebKit with JavaScript API Here are the contents of the sample file: var

Decaffeinated: Double Brackets

对着背影说爱祢 提交于 2020-01-06 07:20:34
问题 I decaffeinated an old project recently and I noticed that I got a lot of if clauses where the expressions are wrapped in "extra" brackets: if ((data == null) || (data === "")) Is there any case where the wrapping is required? Imho it is the same as: if (data == null || data === "") 回答1: In that case it wouldn't matter, but whenever you remove parentheses from an if statement (or anywhere pretty much) make sure you check the precedence table. For example, removing the parentheses from this:

Gem dependency conflict between coffee-rails and rspec-rails

随声附和 提交于 2020-01-06 04:12:04
问题 I'm upgrading an app from rails 3.1.1 to rails 3.2. I had to update version of coffee-rails as well as rspec-rails to their latest versions to work with rails 3.2. However, they both seem to be incompatible with each other. When I run the bunder I get In Gemfile: coffee-rails (~> 3.2.2) ruby depends on actionpack (= 3.2.0) ruby rspec-rails (~> 2.8.1) ruby depends on actionpack (3.0.0) However, on rubygems for rspec-rails, it clearly specifies the dependency to be >= actionpack (3.0.0) Has

Facebook plugin page in Rails Turbolinks doesn't load

跟風遠走 提交于 2020-01-06 02:52:06
问题 in my Rails app I am loading Facebook plugin page, but because of turbolinks it doesnt load each page (only sometimes). I tried this script on this page , but now it never loads. What did I do? I created facebook.coffee with this script: $ -> loadFacebookSDK() bindFacebookEvents() unless window.fbEventsBound bindFacebookEvents = -> $(document) .on('page:fetch', saveFacebookRoot) .on('page:change', restoreFacebookRoot) .on('page:load', -> FB?.XFBML.parse() ) @fbEventsBound = true

Angular injector error with minified JavaScript

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 15:17:43
问题 I have been struggling to find a solution for this problem: I am using Angular.js on my site. I use CoffeeScript to write my JavaScript in Visual Studios 2012. When I save my CoffeeScript - both a minified and un-minified version of the JavaScript file is saved. While using any minified version of JavaScript files on my webpage I keep getting this error: Error: $injector:unpr Unknown Provider Unknown provider: nProvider <- n This error results from the $injector being unable to resolve a

Stripe Integration - Dynamically adding attr value in to the hidden_field

元气小坏坏 提交于 2020-01-05 10:26:10
问题 I'm working on integrating Stripe with my Rails project, and have it working to the point where when a new user signs up they are added as a customer in Stripe. I'm having some problems sending the plan_id to them, however. The URL of the sign up form includes the plan_id as a parameter depending on which plan is selected from the pricing table, for example: http://localhost:3000/users/sign_up?plan_id=1 The sign up form includes the following hidden field, which should pass the plan_id to

Coffeescript + Express: unexpected ,

只谈情不闲聊 提交于 2020-01-05 08:26:34
问题 I'm learning to make an app on Express.js using Coffeescript. I have uploaded my code at: https://github.com/findjashua/contactlist When I try to run the app, I get the following error: app.coffee:11:24: error: unexpected , res.send 'Hello World' ^ I don't understand the issue here. Any ideas? 回答1: On line 11 in contacts.coffee you have exports.index = (req, res) -> ContactModel.find (err, contacts), -> if not err remove that comma on the central line, after contacts) . 来源: https:/

How can I use Private Pub with a Resource Route that has a segment key?

自作多情 提交于 2020-01-05 08:16:28
问题 I'm currently having a problem while using Private Pub in a Rails 3 Project. All the examples show the usage of publish/subscribe to a route like this: "/messages/new" But What If the intended route is a little more complex, ie. routes.rb resources :messages, only: [] do post 'chat', on: :member end Which will create the following chat_message POST /messages/:id/chat(.:format) messages#chat Therefore, I'm using it like this: view: = subscribe_to "/messages/#{@cid}/chat" coffee response view:

Delay (debounce) ajax request with coffeescript

你。 提交于 2020-01-05 07:52:29
问题 I'm using CoffeeScript in my rails app, and I need to delay a remote ajax form submission, the main problem I'm having is debouncing the request so that the form will send once 250ms has passed without the user typing in the the form. Right now I have something that looks like this going on, obviously it won't work so this has some debug output in it to help me out. Taking a look at the table below, you should know that the function that I want to be "debounced" is within the element.keyup

Trouble referencing class object inside a nested function

[亡魂溺海] 提交于 2020-01-05 05:49:29
问题 I'm trying to create a class in coffeescript and I'm almost there. My problem is, I'd like to create a couple of variables for the entire scope of the class, however I don't know how to get to them inside nested functions. @ is equivalent to "this.", however I'd like to be able to get to those constructor properties from anywhere inside the class. Example: class CoffeeScriptClass constructor: (@foo) -> _sampleFunction: -> $.each BigArray, (index, NestedArray) -> $.each NestedArray, (index,