Menu
  • HOME
  • TAGS

Test for Apple Push Notification

node.js,coffeescript,mongoose,apple-push-notifications

In many situations, while writing tests, it is either impossible or simply too dangerous to verify that an action has really taken place (i.e. a push notification has been delivered). Imagine writing a unit test for the rm command where you would like to ensure that doing rm -rf /...

Unique triggering of window.requestAnimationFrame

javascript,coffeescript

Solved. I've forgotten to call window.requestAnimationFrame @update.bind(@) inside update function...

How to disable TableTools buttons in DataTables?

jquery,coffeescript,datatables,jquery-datatables

Try this .. remove the T option from the dom value $('#myTable').dataTable 'dom': 'lfrtip' The T option triggers the initialisation of TableTools....

Framer.js: how to get tap coordinates

coffeescript,framerjs

Check out your own answer to the question. I've since then forked it and made changes so that taps on a computer or taps on a mobile device are recognized separately. https://github.com/carignanboy1/Material-Design-Interactions/tree/improved-touch touchEvent = Events.touchEvent(event) if Utils.isPhone() || Utils.isTablet() tX = touchEvent.clientX - layer.x tY = touchEvent.clientY - layer.y else...

Can I add an else to a simplified if statement?

if-statement,coffeescript

You have to use if...then if you want to use an else: winner = if pick in [47, 92, 13] then yes else no However, you can still do multi-line ifs: if pick in [47, 92, 13] winner = true else winner = false Also, note that the in operator...

Coffeescript implicit returns impact on performance and side effects

javascript,node.js,express,coffeescript

Nice question! This has been largely discussed in this pull request. Regarding performance Bear in mind that returning undefined or any other value is almost equivalent, performance-wise. However, all differences are quite small, so this shouldn't get you worried. You can compare the actual speed variations in this quick-and-dirty benchmark:...

locating path of a file in meteorjs

javascript,node.js,meteor,coffeescript,npm

if the file should be checked in This is the easy case - just place the file in your private directory and access it with the assets api. For more examples, see my blog post on exactly this subject. if the file should exist somewhere else on the server Use...

JQuery attr() on div not returning value

jquery,coffeescript,attr

When iterating over a jQuery object the element reference will be referring to the DOM element not a jQuery object so you can't access jQuery methods directly on it console.log "ALL", $('.contact') for div in $('.contact') console.log $(div) console.log $(div).attr('cid') Use .each() like console.log "ALL", $('.contact') $('.contact').each (i, div) ->...

Rails: redirect_to:back not redirecting in spite of showing correct logs

javascript,ruby-on-rails,ruby,angularjs,coffeescript

Your problem is that your are redirecting only the XHR request made by javascript -- the page shown to the user remains unaffected. To look at this in more detail, when your form is submitted, you trigger some code. This code makes an HTTP post to the server. The server...

Reactjs best strategy to define a variable for render method

javascript,coffeescript,reactjs

This solution is better, in my opinion: @AuthPanel = React.createClass getAuthComponent: -> if @props.uiState.auth_panel?.signed_in return <SignOutForm uiState={@props.uiState} socket={@props.socket} /> else return <SignInForm uiState={@props.uiState} socket={@props.socket} /> render: -> <div className="navbar-collapse"> {@authComponent()} </div> I've found it there: https://github.com/planningcenter/react-patterns#sub-render...

how to use js.coffee file in rails 4

jquery,ruby-on-rails,ruby-on-rails-4,coffeescript

You can actually rename product.js.coffee file to product.js. Just include the product.js file in application.js Whether the file .js extension or js.coffee extension, Rails uglifier compiles and mififies the file to js file. So, If you write coffe script code, then it will be compiled to javascript file. http://guides.rubyonrails.org/asset_pipeline.html#javascript-compression...

What's this Coffescript use of then?

syntax,coffeescript,semantics

Of course ... It calls the newcard.save().then function - thanks @rightfold - which is in the Angular.js promises api. Not immediately obvious out of context of that api which BTW is nicely explained here.

How do I set a jQuery selector in coffeescript using a variable?

javascript,jquery,ruby-on-rails,coffeescript

Whats happening in your code is that the keypress binding is applied on page load, so its only applied once while plan id is still 0. it doesnt get re-applied when plan_id is updated. I should note this seems like an odd thing to be doing, but you need to...

jstree in complex environment & coffee not showing any icons nor outline

jquery,coffeescript,jstree

Did you include the CSS theme on your page? It is listed as 2) here: http://www.jstree.com/ (Overview tab) <link rel="stylesheet" href="dist/themes/default/style.min.css" /> or <link rel="stylesheet" href="dist/themes/default-dark/style.min.css" /> EDIT: Based on the comments - if you want to use the dark theme, you need to both include the CSS and configure...

Coffescript doesnt point correct element

javascript,jquery,coffeescript

According to your html, .content_length is inside .field_with_errors, so I think you must first get the parent and then do next, like shown below: $(document).on 'keyup', '.content_length', -> $(this).parent().next('.char_counter').text(255 - $(this).val().length); ...

Bluebird nested promises with each/spread

javascript,coffeescript,mongoose,promise,bluebird

Looks like bluebird's .each doesn't go well with .spread Yes indeed. each does return a promise for an array, if you want to use that array just use then: Promise.each [1..3], (number) -> opts = getOpts(number) Model.countAsync(opts).then (count) -> "the count is #{count}" .then (args) -> console.log JSON.stringify args...

Angular: JSON filter in textarea produces a lot of slashes

javascript,json,angularjs,coffeescript

Just remove angular.toJson() because the value is already in json-format!

Coffeescript Inheritance: Static variables/methods

inheritance,express,coffeescript

You were missing a few @s. The following prints I am a child: class AbstractClass @myVar: null @doSomething: -> console.log @myVar class Child extends AbstractClass @myVar: 'I am a child' Child.doSomething() But if you want to pass it as a callback function, you need to bind it to Child: callf...

setInterval() keeps Node.js process running

javascript,node.js,coffeescript

What I want to do is to tell Node.js that this setInterval in not important, you can terminate it if everything else is done. How can I achieve that? You are looking for the unref method, which "will allow you to create a timer that is active but if...

Backbone.Deferred.Model: Why the unittest is not run?

backbone.js,coffeescript,phantomjs,mocha,chai

Your test case should be defined using the it function instead of describe (which is used to group tests) define (require) -> Data = require 'model/Data' describe 'dataurl', -> it 'No change', -> data = new Data id: '123', name: 'Dummy', data_url: 'https://m/a.png' expect(data.dataUrl()).to.equal('https://m/a.png') I have created this jdfiddle so...

PyCharm coffee filewatcher

django,coffeescript,pycharm

So i got the desired result by this macros: $FileParentDir(coffee)$/js/$FileDirPathFromParent(coffee)$ ...

Gulp compiling SLIM/SASS/CoffeeScript on fly

coffeescript,sass,gulp,slim-lang

You need to put watchers on your files: gulp.task('watch', ['build','connectDist'], function() { gulp.watch(['./app/**/*.coffee', '!./app/bower_components/**'], ['minify-js']); gulp.watch(['./app/**/*.scss', '!./app/bower_components/**'], ['minify-css']); gulp.watch('./app/**/*.slim', ['copy-html-files']); }) If you start gulp watch, first the build and connectDist tasks are getting executing, preparing your build directory. Then three watchers look at your main input files, and call...

Post forms with coffescript/ ajax in play

ajax,forms,playframework,coffeescript

Thanks to Infinity and the new console error input I noticed that jsRoutes.controllers.Questions.create.ajax must be jsRoutes.controllers.Questions.create().ajax ...

How to call python from coffeescript

angularjs,python-2.7,coffeescript

you want to use the builtin $http service to make the call to the server. For some sugar you have the option of using the $resource service which wraps the $http service. Ideally you'd create a method in a service of your own making to call from your controller.. my...

Why does Codepen.io not show a thumbnail / preview for this pen?

javascript,jquery,coffeescript

Perhaps a loop with too many iterations causes the preview to hang This help article may apply: Turn Off JavaScript in Previews "On any page that displays a grid of Pens as live previews… This can be useful if you…accidentally create a Pen with JavaScript that is taking to long...

D3.js ( in Coffeescript) show data on click

javascript,d3.js,coffeescript,data-visualization

Even though I'm not completely sure of your code I think this should work: updateActive = (id) -> node.classed("bubble-selected", (d) -> id == idValue(d)) if id for x in data when idValue(x) is id d3.select("#comment").html(commentValue(x)) else d3.select("#comment").html("<h3>Click on a bubble to read its comment.</h3>") Here data is what you supply...

Extend Coffeescript subclass function from parent in marionette

javascript,backbone.js,coffeescript,marionette

In Backbone, when you inherit from another class, Backbone will give the subclass a __super__ property (double underscore at both ends) which is the prototype of the parent class. So from within your Views.NewUser class, you can get the prototype via View.NewUser.__super__. Then, you can call templateHelpers on that object....

unable to handle HTTP 422 with best in place rails

jquery,ruby-on-rails,coffeescript,best-in-place

This is the code that finally worked. $('.best_in_place_cart_quantity').best_in_place() $(".best_in_place_cart_quantity").bind 'ajax:error', (evt, data, status, xhr) -> alert "Not enough quantity" Lesson learnt was that, we should bind best in place fields through class instead of Id....

How to initialize ng-model of input checkboxes in an ng-repeat loop

javascript,angularjs,checkbox,coffeescript

You can use ng-init to populate the array. I used $index rather than making up a bunch of data with id properties...adjust your code accordingly <input type="checkbox" ng-model="selectedMessages[$index]" ng-init="selectedMessages[$index]=selectedMessages[$index]||false" /> JS $scope.selectedMessages=[]; $scope.checkAll=function(){ var msgs = $scope.selectedMessages msgs.forEach(function(elem, idx){ msgs[idx] =true }) } DEMO...

How to require other CoffeeScripts files in main CoffeeScript with Laravel?

php,laravel,coffeescript,asset-pipeline,laravel-elixir

As there is no answer, I have to explore the solution by myself and here is the one. In Laravel-elixir version (2.3.6), there is a concatenation feature for coffeescript. You have to store coffeescript files in resources/assets/coffee directory. Then, the following script in gulpfile.js will generate a single app.js that...

Clearing Session data

javascript,ruby-on-rails,ruby-on-rails-4,coffeescript

As mentioned in my comments to nesiseka i was not able to make it work the way he suggested so I went ahead with the following solution. Controller: def clear_cart session.delete(:product_quantity) if request.post? redirect_to shopping_index_path end end view: <%= simple_form_for(:place_order, :url => "#{}", html: {id: "place_order" }) do |f| %>...

How to insert user_id to coffeescript file

javascript,ruby-on-rails,coffeescript

It is possible when the html is being generated. One way is to put in the bottom of your file js code which assigns user's id to globally available configuration and then read this id from this variable. for example in your erb <%= javascript_tag do %> window.Configuration = {};...

getWindowHandle() Selenium Webdriver Javascript

javascript,selenium,coffeescript

var parent = driver.getWindowHandle(); var windows = driver.getWindowHandles(); driver.switchTo().window(windows[1]); // do some stuff driver.close(); driver.switchTo().window(parent); ...

Rails submit_tag form validation

ruby-on-rails,coffeescript

So this feels a little busy, but it works. Feel free to make suggestions... jQuery -> $group = $('.form-group.registration_form') if $group.length $(".location").hide() $(".location-section-link").hide() $(".submit_register").click -> if validateForm() == false return false else if validateEmail($("#email").val()) == false alert('Please enter a valid email address') return false else $(".location").show() $(".location-section-link").show() $(".registration_form").hide() #validate email...

Can I use CoffeeScript to write my Electron (Atom Shell) application?

coffeescript,electron

They is no way to do it (atom doesn't ship with a coffeescript compiler), but you can use the watch option of coffeescript -w, --watch watch scripts for changes and rerun commands for example: coffee -w main.coffee in your case...

Websocket establish bulletproof connection

javascript,firefox,websocket,coffeescript

Its not actually throwing an Error, the program execution continues. Its simply logging the error (asynchronously) to the console. To handle connection failures, you can bind to the sockets onerror event. Something like this could work: function establishWSConnection(url) { return new Promise(function(res, rej) { var ws = new WebSocket(url); ws.onerror...

Service property not updating consistently

javascript,jquery,ember.js,coffeescript

Turns out this problem goes away if I store the editorState on the controller, and look up this.controller.editorState in the route willTransition action handler. Thanks Grapho and locks on IRC ;)...

One of two animations doesn't work on page load jQuery

jquery,css,coffeescript

If you want to animate it, either up or down then have down because up have it hidden so you will not be able to see it. Try this: $("#welcome").slideDown(1000); $("#apples").slideDown(1050); ...

python-like interpolation of string in coffeescript

python,string,coffeescript,string-interpolation

You can make all those entries a functions, then apply a dictionary to them with arguments: errorMessages= error404Find:-> "Hosts not found" error404FindByHost:-> "Host - #{@hostName} - not found" error400:-> "No host" alert errorMessages["error404FindByHost"].apply hostName:"host1" ...

Is there a way to concatenate JS and CoffeeScript files using Harp server?

javascript,coffeescript,harp

I ended up customizing the terraform module, writing a preprocessor called man. Here is the diff from Harp: https://github.com/sintaxi/terraform/compare/master...thesmart:master...

ECMA 6 postfix condition use-cases

javascript,coffeescript,ecmascript-6

You got it wrong. Postfix conditional won't be a part of ES6, that's a feature of CoffeeScript. In presentation they are mentioned in What's missing? [from ES6 that is present in CoffeeScript] section. Also there is no is operator in JavaScript, neither it is planned for ES6/ES7.

Chrome extension popup has a 2 - 3 second delay

javascript,performance,google-chrome-extension,coffeescript

So it turns out that the checkOnline() method was taking a wee while to return and blocked the rendering of the popup. This is the checkOnline() method, in Coffeescript: checkOnline = -> online = navigator.onLine return online The solution was to put this (and another method that relied on it)...

Coffeescript evaluates only once

ruby-on-rails,checkbox,coffeescript

Here you go, I hope that this is what you are looking for: boxes = $('#checkboxlist [type=checkbox]') selectAll = $('.selectall') toggleCheckboxes = -> if $(this).is ':checked' then boxes.prop "checked", true else boxes.prop "checked", false selectAll.on 'click', toggleCheckboxes Fiddle You should change attr() to prop(). Nothing special happening here, we have...

Set Session with usernames value

meteor,coffeescript

Your helper is running before your user has fully logged in. You can avoid the error by adding a guard like so: Template.dashboard.helpers 'setUsernameToSession': -> Session.set 'username', Meteor.user()?.username However, you really shouldn't be doing this in the first place because helpers should be side-effect free - see the 'overworked helpers'...

How to access a variable across CoffeeScript functions?

javascript,coffeescript,global-variables

You simply need to declare somecount in a scope that the other functions are also in: somecount = null foo = -> alert somecount bar = -> alert somecount -> someCount = 123 foo() bar() ...

Angularjs service typerror undefined is not a function

javascript,angularjs,coffeescript

It looks like you are returning the function itself as service. Instead just do not return the function, service gets newed up by the injector just attach the method to its instance and return nothing. In your original case you would have to invoke it as CalculateService(student) Try: App.service 'CalculateService',...

How to bind response of Ajax request to Model in EmberJs?

javascript,ruby-on-rails,ember.js,coffeescript,emblem.js

So, here is what I did to achieve it, I made a function in controller to make it available in emblem template for records to loop over it. And in that function called @get('model') to get all the records from Ember Data Model. (Which I was doing with 'controller' in...

ActionController::RoutingError Rails and Angular

javascript,ruby-on-rails,angularjs,coffeescript,restangular

I have solve this problem by renaming show.json.jbuilder to show.jbuilder and just use Restangular.one('products', 6862).get().then (c) -> ...

path to assets in Wordpress using jQuery

jquery,wordpress,coffeescript

you're writing php code in a javascript document. id suggest in your header.php put this code <script>var templateDir = '<?php echo get_bloginfo('template_directory');?>';</script> ...

Coffeescript and ReactJS documentation

coffeescript,reactjs

Finally, it seems that nothing exists. Thus I built one very naive implementation here. https://github.com/kursion/broffeact...

Coffeescript and Ecmascript 6 get and set keywords

coffeescript,ecmascript-6

I don't think Coffeescript does support getter/setter declaration in object literals at all. It's been discussed multiple times, see issues 64, 451, 322, 2878: In summary: we explicitly ignore the existence of setters/getters because we consider them a bad part of JS The best workaround you can get is Object.defineProperty...

In lodash.js, will it cache the result for `.value()` method?

javascript,coffeescript,underscore.js,lazy-evaluation,lodash

When you create a lodash wrapper, the wrapped value is stored within the wrapper. For example: var wrapper = _([ 1, 2, 3 ]); Here, [ 1, 2, 3 ] is stored in wrapper, and any chained operations added to the wrapper are passed this value. Chained operations are stored,...

Coffeescript incorrect scope of @ when passing method as callback

javascript,coffeescript

Why not use the fat arrow for the functions belonging to the class, thus binding them correctly to the context of the class (and it's instances) - this is more how it is intended to work. module.exports = class InviteCreateSocket extends AbstractSocket register: () => @socket.on 'invite:create', @create return create:...

CoffeeScript: calculate parse tree (like coffee -n) in a program

coffeescript,parse-tree

Just look in the source: the -n flag invokes (require 'coffee-script).nodes. The result is a syntax tree which corresponds to grammar.coffee and would be interpreted with nodes.coffee. So this: (require 'coffee-script').nodes 'square = (n)->n*n' Will give you a syntax tree. Before you print it, you could use its toString method...

Rails 4 jQuery, javascript and coffee scripts not working

javascript,jquery,ruby-on-rails,ruby,coffeescript

To resolve this issue I created a blank app with just a 'welcome' controller, containing only the jQuery test script, which worked fine. Working backwards from the differences in the trees from the naked application, I found that another developer had generated an empty coffeescript file: app/assets/javascript/application.coffee I removed this...

Jasmine spyOn with multiple returns

javascript,angularjs,coffeescript,jasmine

With spyOn you can return mocked value and set it dynamically like in following code it 'should place the component as last object in the form', -> mockedValue = null spyOn(window, 'prompt').and.returnValue(mockedValue) mockedValue = 'test' builder.addFormObject 'default', {component: 'test'} mockedValue = 'test2' builder.addFormObject 'default', {component: 'test2'} expect(builder.forms['default'][0].name).toEqual('test') ...

Access class instance from a function passed into a React component and triggered there

javascript,backbone.js,coffeescript,reactjs

Using CoffeeScript, you just need to use a fat arrow function to automatically bind the FoodView::doSomething method to the instance. See also Bound functions. class FoodView extends Backbone.View doSomething: (e) => // `@` refers to the FoodView instance which is equivalent to class FoodView extends Backbone.View constructor: -> @doSomething =...

How to combine js lines into one?

coffeescript,mootools

Although what @sergio gave you is the correct answer and what you wanted, it's probably the wrong thing to do (though his answer is not at fault, its the question that is off). Setting element inline styles in JavaScript for effects is just not a very good practice. It has...

Get variable of a class out of the scope with coffeescript

javascript,coffeescript

If the API you're after is this validator = new Validator() validator.errors.all() then place the errors object within the constructor and also change errors: first: -> to errors = first: -> Otherwise, just change errors: first: -> to errors: -> first: -> making the API look like this validator.errors().all()...

Theoretical Coffeescript Switch Statement Conundrum

javascript,coffeescript,switch-statement,theory

I wouldn't call this an issue, because it works as expected :-) For the reason, I can only guess (maybe there are some comments in the compiler). It is most likely that they needed to cast all of these expressions to boolean values - they want it to work like...

Compile CoffeeScript to particular Javascript file

javascript,coffeescript

The -o option specifies the output directory. You sholud get the expected output if you remove the file name from this argument. To compile without the top-level function safety wrapper, use the -b option. Please read about the coffee command options here: http://coffeescript.org/#usage...

Item not being pulled from array after navigating away from and back to page in Meteor app

mongodb,meteor,coffeescript

I'm not completely sure why this is failing. It could be because you are storing user objects instead of ids, and their fields must be exactly equal in order for the update to work. I'd strongly recommend reworking your schema to use an array of ids instead of objects. It's...

Waiting for Nested Promises to complete

ember.js,coffeescript,promise

You need to return promises from your then callbacks so that you can properly unnest them. So first return the item promise from that callback and get a promise that you can actually push to your promises array immediately in that loop: promises = [] @get('itemsInMyController').forEach (item) => promise =...

AngularJS - Form scope binding in ng-include templates

angularjs,forms,coffeescript,jade,angularjs-ng-include

A plunkr would be nice to actually test your code, but I noticed a typo in your example code: ng-model: 'data.funding_opportunity.details', should be ng-model='data.funding_opportunity.details', Check if it works by correcting the typo and otherwise please provide a working example...

Share two instances between other classes

javascript,coffeescript

It sounds to me as though one and two shouldn't be classes at all, just single objects: one = { data: "I'm one", method: () -> # do something # if needed, you can use two here } two = { data: "I'm two", method: () -> # do something...

React.js implement UI effects after mounting

javascript,dom,coffeescript,reactjs,react-jsx

To integrate with a non-React DOM library, as @WiredPrairie said, you'll need to utilize componentDidMount. However, you can encapsulate that logic in a custom component, so you only have to do it once. For example, you used the code: componentDidMount: -> phoneInput = $(React.findDOMNode(@refs.phone)) phoneInput.bfhphone(phoneInput.data()) Imagine you had several such...

Creating functions containing HTML

javascript,html,string,function,coffeescript

Since this is CoffeeScript, you can use string interpolation: ballon1 = (text1) -> "<a href=\"#balloon1\">Open Modal</a> <blockquote class=\"balloon\" id=\"balloon1\"> <p>#{text1}</p> <a href=\"#close\" title=\"Close\" class=\"close\">X</a> </blockquote>" You could also switch to single quotes in your HTML to avoid all the backslashes: ballon1 = (text1) -> "<a href='#balloon1'>Open Modal</a> <blockquote class='balloon' id='balloon1'>...

what does “:” mean in this case in coffee script?

coffeescript

Appending mu is too short's answer (the user is absolutely correct that the second parameter commandNamecan be an object without the explicit braces {}) Atom's sourcecode: https://github.com/atom/atom/blob/v0.198.0/src/command-registry.coffee#L81 add: (target, commandName, callback) -> if typeof commandName is 'object' commands = commandName disposable = new CompositeDisposable for commandName, callback of commands disposable.add...

Write Ajax function in Coffeescript?

javascript,jquery,ajax,coffeescript

$ -> download_to_textbox = (url, el) -> $.get url, null, ((data) -> el.val data return ), 'text' download_to_textbox 'http://code.jquery.com/jquery-latest.min.js', $ 'textarea' $("textarea").click -> $(this).select() ...

Rails Best_in_place ajax:success not being recognized

ruby-on-rails,ajax,coffeescript,best-in-place

The issue is resolved. The problem was not that ajax:success wasn't firing, it's that (for reasons still unknown) I had to read ajax:success at the table body level instead of the table cell in question. Apparently this is a somewhat common issue, where when adding new elements to the DOM...

Coffescript and multiple arguments

coffeescript

You cannot put a space between a method name and the parenthesis used to invoke it. If you do, the parenthesis are no longer part of the function invocation, they're for order-of-operations on the arguments to the function. Consider a few examples of valid and invalid syntax: x() is a...

using underscore to total array elements with coffee script

javascript,coffeescript,underscore.js

There's no need to call _.reduce twice for this. The memo for reduce can be anything; in particular, it can be an object: summer = (memo, it) -> memo.goodsTotal += it.price memo.goodsVAT += it.vat memo totals = _(invoicedItems).reduce( summer, { goodsTotal: 0, goodsVAT: 0 } ) ...

Rails 4 - Layouts only showing half the time with javascript

javascript,ruby-on-rails,coffeescript

document.write will erase everything in the html before writing to it, that's why you only see the image. You should do something like this instead: placeholder = document.getElementById("placeholder") placeholder.innerHTML = '<img src="url' + number +'.jpg">' where placeholder is an existing element in the html with id of "placeholder"...

Object literal multiple assignment in CoffeeScript

javascript,json,node.js,coffeescript

This is known as Destructuring Assignment. To make extracting values from complex arrays and objects more convenient, CoffeeScript implements ECMAScript Harmony's proposed destructuring assignment syntax. When you assign an array or object literal to a value, CoffeeScript breaks up and matches both sides against each other, assigning the values on...

async.mapLimit usage to make multiple requests

javascript,node.js,asynchronous,coffeescript

getCertificatesFromPage = (url, callback) -> You are not calling the callback in the getCertificatesFromPage function. Without that, the framework cannot know when the work is done....

Can't call fetch directly in Backbone model listenTo

javascript,backbone.js,coffeescript

The handler for each type of event is passed a certain set of arguments. The Catalog of Events has this to say about a "change" event: "change" (model, options) — when a model's attributes have changed. So if you say this: this.listenTo(members, 'change', this.fetch) then fetch will be called like...

require (browserify) not working correctly when assigned (empty object), but works when inline

javascript,coffeescript,reactjs,browserify

Usually when you get an empty object from a require call, it's because you have circular dependencies. So you require A, which requires B, which requires C, which requires A. In that case C will get an empty object representing A, because A hasn't finished exporting its functions/objects yet and...

Dynamically generate React component names

coffeescript,reactjs

I couldn't get Crob's answer to work (though I appreciate the hash table idea), but it led me to find a solution - I just skipped the jsx step and used the compiled js: React.createElement(component, {tasks: this.props.tasks} ) So all in all: var Components = { 'something': require('./Component'), 'somethingElese': require('./Component2')...

How to test if class instance is instance of class that it extends?

coffeescript

class A class B extends A b = new B console.log "b is an instance of extended class " if b instanceof B # b is an instance of extended class console.log "b is an instance of extended class A because B extends a " if b instanceof A #...

How do I automatically compile Coffeescript using Typesafe?

scala,playframework,coffeescript,typesafe-activator

I think the root cause might be related to the activator UI running Play in prod mode vs develop mode. This question is similar: How to run play project in dev mode with Typesafe Activator UI According to Play CoffeeScript Page CoffeeScript sources are compiled automatically during an assets command,...

Handlebars: return hash from helper

javascript,backbone.js,coffeescript,handlebars.js,handlebars

Handlebars will see this: {{show.key1}} as an attempt to access the key1 property of the show variable, it won't know that show in this case is supposed to refer to your show helper. This is just part of Handlebars syntax and I don't think there's anything you can do about...

Sort array of objects in javascript with user input

javascript,arrays,angularjs,sorting,coffeescript

You can use orderBy with custom comparer, something like in next sample. Here on top would be object where name started with entered text angular.module('app', []) .controller('ctrl', function($scope, $filter) { $scope.arr = [{ "id": 1, "name": "android", "taggings_count": 5, "category": null }, { "id": 2, "name": "ruby", "taggings_count": 7, "category":...

Dynamic className in cjsx

coffeescript,reactjs

The hide property is set on @state, not on the component instance. if @state.hide then "hidden" ...

How to export a function from a module to another in coffeesricpt?

coffeescript,amd

This: define (require) -> doSomething(a, b, c) -> "#{a}?#{b}&amp;#{c}" isn't a function definition. That is really this in disguise: define (require) -> return doSomething(a, b, c)( -> "#{a}?#{b}&amp;#{c}") so your module is trying to call the doSomething function and then call what it returns as another function which takes a...

Add Extra Field_for in Nested form with Rails 4

javascript,ruby-on-rails,ruby-on-rails-4,coffeescript,nested-forms

You can use Cocoon. Cocoon makes it easier to handle nested forms.

Reactjs working with sockets: rerender when socket receive a message

javascript,websocket,coffeescript,reactjs

You shouldn't mutate @state directly, but instead use setState to enqueue a state update which, once performed, will cause the component to re-render. You should consider @state and its value as read-only most of the time. In your case, replace @state.signals.push { message: event.data, direction: 'in' } with @setState signals:...

Angular directive: return object from collection

javascript,angularjs,angularjs-directive,coffeescript

You should use require: 'ngModel' to inject the model attached to the element or its parent element on which the directive is bound to. Here is a demo.

How to map Visual Studio shortcut keys in Github Atom

visual-studio,coffeescript,atom-editor

Open the Settings panel by pressing ctrl-, on windows cmd-, on mac and select the Keybindings tab. It will show you all the keybindings currently in use. You can also open the keybinding resolver using ctrl-. and press ctrl-k and see what keybinding it displays. To assign custom keybindings, go...

AngularJS - Losing controller scope within method

javascript,angularjs,coffeescript

I don't know if this qualifies as an answer. I was not actually calling $scope from within the controller method. If you $scope.book then $scope is available in the debugger.

Using after to clean up in mocha, problems with mongo

node.js,mongodb,coffeescript,mocha

Mongo doesn't have enough time to connect, Try using the done callback in after function: after (done) -> console.log "WHYYYY" mongo.open (error, db) => ... done() console.log "exit after" }) ...

Show the subcategories of the chosen category in Rails 4

javascript,ruby-on-rails,ruby-on-rails-4,model-view-controller,coffeescript

Look in your console or development.log and you're going to see some message indicating that rails could not resolve update_sub_categories when your script fails. Wheras when calling that method with a new form, you'll see that rails is calling your_controller/your_action/update_sub_categories -- you can probably see where this is going now....

Coffeescript - assign if value is defined

javascript,coffeescript

Well, if it's a common case, you could write a function, but I only can come up with one that has the property you want to assign to in quotes. I don't think there is some syntactical sugar for that case (as you have stated, you don't want a null...

Do not allow decimal numbers in textfield on form submittion in CoffeeScript

jquery,coffeescript

I would not allow the decimal . character: jQuery(document).ready(function () { jQuery(".no_decimal").keydown(function (e) { if (e.keyCode == 190) return false; }); }); The above in CoffeeScript: jQuery(document).ready -> jQuery('.no_decimal').keydown (e) -> if e.keyCode == 190 return false return return If you still insist on checking only on Form Submission, use...