coffeescript

Can't find reason why xhr is not defined

大兔子大兔子 提交于 2019-12-25 00:42:09
问题 I am getting an uncaught reference error: XHR is not defined in my coffeescript below. jQuery -> # Create a comment $(".comment-form") .on "ajax:beforeSend", (evt, xhr, settings) -> $(this).find('textarea') .addClass('uneditable-input') .attr('disabled', 'disabled'); .on "ajax:success", (evt, data, status, xhr) -> $(this).find('textarea') .removeClass('uneditable-input') .removeAttr('disabled', 'disabled') .val(''); $(xhr.responseText).hide().insertAfter($(this)).show('slow') # Delete a

Coffeescript jQCloud handlers

余生长醉 提交于 2019-12-24 22:32:02
问题 I'm trying to do this in coffeescript, http://jsfiddle.net/Q6348/8/ Specifically I'm trying to add handlers to my jQWordCloud to get the label for the word being clicked on In my coffeescript version while i < @counts.length x = @counts[i] @tag_list.push text: x.label weight: x.count handlers: click: -> temp = x -> alert "it worked for " + temp.label () ++i I get an unexpected TERMINATOR error presumably because of the (), but if you notice on the jsfiddle, removing that breaks the handler

Meteor and CoffeeScript: Cannot call method 'helpers' of undefined

自闭症网瘾萝莉.ら 提交于 2019-12-24 17:37:08
问题 I just set up CoffeeScript (I'm also using Jade) for Meteor and it seems that my helpers (rendered and events functions too) do not work anymore. Template.signIn.helpers showForgotPassword: () -> return Session.get('showForgotPassword') The code seems to be properly generated but is embraced in an anonymous function. I'm getting the following error in the web console: Uncaught TypeError: Cannot call method 'helpers' of undefined (account.coffee:12) I'm wondering whether the code is run before

convert async.eachLimit to promise

我与影子孤独终老i 提交于 2019-12-24 17:33:02
问题 I have such aync code async.eachLimit(teams, 1000, fetchTeamInfo, exit) I need to convert it to Promise (bluebird) I thought will be good to make something like: Promise.method (teams, 1000, fetchTeamInfo) -> async.parallelLimit arr.map((a, i) -> -> iterator a, i, arr ), limit But not sure is it right way 回答1: Well, I see you're using Promise.method so I'm assuming bluebird - bluebird comes with Promise.map with already supports what you're looking for with the concurrency parameter: const fn

convert async.eachLimit to promise

南楼画角 提交于 2019-12-24 17:31:41
问题 I have such aync code async.eachLimit(teams, 1000, fetchTeamInfo, exit) I need to convert it to Promise (bluebird) I thought will be good to make something like: Promise.method (teams, 1000, fetchTeamInfo) -> async.parallelLimit arr.map((a, i) -> -> iterator a, i, arr ), limit But not sure is it right way 回答1: Well, I see you're using Promise.method so I'm assuming bluebird - bluebird comes with Promise.map with already supports what you're looking for with the concurrency parameter: const fn

How do Atom's 'spec' files work?

北战南征 提交于 2019-12-24 16:06:57
问题 I'm making a package for Atom, and Travis CI keeps telling me my build failed. Update : I created a blank spec file and now my builds are passing. You can see my package here: https://travis-ci.org/frayment/language-jazz The console is telling me: sh: line 105: ./spec: No such file or directory Missing spec folder! Please consider adding a test suite in I went looking around at Atom packages on GitHub for 'spec' files and they seem to be CoffeeScript based, but I can't understand what on

mongo/node TypeError: callback is not a function on query

a 夏天 提交于 2019-12-24 15:42:58
问题 I am trying to determine if a document exists in a collection. If the document exists, I wish to add a property "unread = false" to an object. If it does not exist, I wish to insert the document and add "unread = true" to the object. Code in coffee script for the above is as follows: functionxyz = (db, uid, events, done) -> async.each events, (eventobj) -> if db.Event.find(eventobj).count() > 0 eventobj.unread = false else db.Event.insert eventobj eventobj.unread = true done null, events The

Hubot matching on multiple tokens per line?

泪湿孤枕 提交于 2019-12-24 15:03:12
问题 How can I match on multiple occurrences of a token in a single message. module.exports = (robot) -> robot.hear /ITEM=(\d+)/, (msg) -> msg.send 'matched='+msg.match I would like to be able to match: blah blah blah ITEM=100 ITEM=200 ITEM=300 blah blah However I only get the first match with above code: match=blah blah blah ITEM=100 ITEM=200 ITEM=300 blah blah,ITEM=100 I can always just take the message and manually parse each line for each item, but it seems that using robot.hear should be able

jQuery “Object function (e,t){return new v.fn.init(e,t,n)} has no method 'on'”

女生的网名这么多〃 提交于 2019-12-24 13:47:17
问题 I'm following @coreyward's example for putting object edit forms in modal dialog windows in Rails, which is outlined in this answer and updated for rails 3.1 in this gist. I'm using Rails 3.2.8 and jQuery-Rails 2.1.3 (jQuery 1.8.2 is what's loading in the app). However, this coffeescript from the gist raises the error in the title, on line 7 (right after the comment). $ -> $modal = $('#modal') $modal_close = $modal.find('.close') $modal_container = $('#modal-container') # Handle modal links

Declaring backbone extension class in another file - coffeescript

烂漫一生 提交于 2019-12-24 13:44:18
问题 I have the following class that extends Backbone.View, I want all my backbone views to inherit from this class: class BaseView constructor: (options) -> @bindings = [] Backbone.View.apply(@, [options]) _.extend(BaseView.prototype, Backbone.View.prototype, { #etc. tec. BaseView.extend = Backbone.View.extend I can then extend my own view like this: class BusinessUnitsView extends BaseView initialize: (options) -> This all works fine if they are in the same file but if I separate BaseView into a