Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:37:59+00:00 2026-06-03T14:37:59+00:00

Answer: It turns out I had neglected to use the new keyword when creating

  • 0

Answer:

It turns out I had neglected to use the new keyword when creating the class instance. The code in the question itself is fine.

Question:

I have a fairly simple class where the constructor calls another method on the class (editor_for_node). The call happens inside a jQuery each() loop, but I’ve also tried moving it outside.

define ['jquery'], ($) ->
  class Editor
    constructor: (@node, @data, @template) ->
      @node.widgets().each (i, elem) =>
        data = if @data then @data[i] else null
        node = $(elem)
        @editor_for_node node, data

    editor_for_node: (node, data) ->
      console.log 'hello!'

  return {
    'Editor': Editor,
  }

When the line @editor_for_node node, data gets called, I get an error (in Firebug) saying this.editor_for_node is not a function.

I really can’t see why this isn’t working properly, the only possible source of weirdness that I can see is my use of require.js’s define function at the start.

Edit: Generated output

(function() {

  define(['jquery'], function($) {
    var Editor;
    Editor = (function() {

      Editor.name = 'Editor';

      function Editor(node, data, template) {
        var _this = this;
        this.node = node;
        this.data = data;
        this.template = template;
        this.node.widgets().each(function(i, elem) {
          data = _this.data ? _this.data[i] : null;
          node = $(elem);
          return _this.editor_for_node(node, data);
        });
      }

      Editor.prototype.editor_for_node = function(node, data) {
        return console.log('hello!');
      };

      return Editor;

    })();
    return {
      'Editor': Editor
    };
  });

}).call(this);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:38:01+00:00Added an answer on June 3, 2026 at 2:38 pm

    First: Which version of CoffeeScript are you using? The fat arrow has been a source of bugs in certain previous releases.

    If you’re using the latest (1.3.1), then I’m going to go ahead and say that this is an indentation issue. When I copy and paste your code, it works fine. Are you mixing tabs and spaces? Verify that the compiled output contains the line

    Editor.prototype.editor_for_node = ...
    

    Update: See the comments on this answer. Turns out the problem was that the new keyword wasn’t being used when invoking the constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my question and apparently this is the answer . Turns out it
Answer solved in edit below I had this piece of code Dictionary<Merchant, int> remaingCards
This answer explains how to create test cases dynamically. The answer's code: class Tests(unittest.TestCase):
As it turns out, this question asked the same thing Detach (move) subdirectory into
Note up front, my question turns out to be similar to SO question 1668172
Following my previous question came a quick and great answer, however it turned out
[EDITED to add: It turns out that the answer is very boring and has
[ANSWER] Thanks everyone! The code to solved the problem below is: SELECT ID FROM
Answer : Implemented using Curl... $file = http://abc.com/data//output.txt; $ch = curl_init($file); $fp = @fopen(out.txt,
Having a chain of instanceof operations is considered a code smell. The standard answer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.