/    Sign up×
Community /Pin to ProfileBookmark

this undefined, trying to find error

I’m going through chapter 11 of the big nerd ranch front end dev guide and I’m having a problem. on the line this.$element.append(rowElement.this.$element) I get a can’t append to undefinded error and I don’t know why. I really need some help. the rest of the files are at [url]https://github.com/DanielSollis/coffeerun[/url]

[CODE](function (window) {
‘use strict’;
var App = window.App || {};
var $ = window.jQuery;

function CheckList(selector) {
if (!selector) {
throw new Error(‘no selector provided’);
}

this.$element = $(selector);

if (this.$element.length === 0) {
throw new Error(‘could not find element with selector: ‘ + selector);
}
}

CheckList.prototype.addRow = function(coffeeOrder) {
var rowElement = new Row(coffeeOrder);
this.$element.append(rowElement.$element);
};

function Row(coffeeOrder) {
var $div = $(‘<div></div>’, {
‘data-coffee-order’: ‘checkbox’,
‘class’ : ‘checkbox’
});

var $label = $(‘<label></label>’);

var $checkbox = $(‘<input></input>’, {
type: ‘checkbox’,
value: ‘coffeeOrder.emailAddress’
});

var description = coffeeOrder.size + ”;
if (coffeeOrder.flavor != ”) {
description += coffeeOrder.flavor + ”;
}
description += coffeeOrder.Coffee + ”;
description += ‘ (‘ + coffeeOrder.Email + ‘)’;
description += ‘ [‘ + coffeeOrder.strength + ‘x]’;

$label.append($checkbox);
$label.append(description);
$div.append($label);

this.$element = $div;
}

App.CheckList = CheckList;
window.App = App;
})(window);[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@rootOct 09.2017 — The only way to trace this type of bug is to stop using Anonymous functions like you have posted, then open the console (F12) and read the errors you see. It will then give you proper line numbers.

If you are using JQuery, then your question should be asked in the JavaScript Frameworks Forum.
×

Success!

Help @fkinthecoffee spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...