【发布时间】:2019-11-02 13:25:35
【问题描述】:
最近我开始练习 javascript/jQuery。 我有一份班级问卷。
class Questionnaire {
constructor (json, container) {
// constructor stuff
}
processAnswers() {
// Do something
}
showQuestionnaire() {
// A lot of stuff happens here
// HTML gets build in this method and added to an excisting container.
// The element with class 'button_confirm' gets generated here as well.
// this.container is an excisting HTML DOM-Object (Div)
$(this.container).find('.button_confirm').on('click', function () {
this.processAnswers();
});
}
}
一切顺利,但是当我按下按钮并触发事件时,我收到一条错误消息,告诉我 processAnswers 不是函数。
我做错了什么?为什么我不能从这里调用 processAnswers? 这可能是一个简单的修复,但我没有看到错误。
提前致谢。
【问题讨论】:
标签: javascript jquery class methods