Reputation: 2245
I have some class with some functions and properties
exports.textareaWidget = class textareaWidget extends Widget
name = null
getHtml: ->
this.generateHtml(widgetHtml)
Then I create an object and add to array:
obj = new w.textareaWidget()
obj.name = "msgBody"
console.log obj.getHtml() # works
arr.push(obj)
# getting from arr
for field in arr
result = result + field.getHtml()
When I want to get it from array I can access properites (name) but I can't access functions (getHtml). Why and how can I make it working ? The error:
TypeError: Object #<Object> has no method 'getHtml'
Upvotes: 3
Views: 103
Reputation: 173562
You probably mean to indent the name
and getHtml
definitions:
exports.textareaWidget = class textareaWidget
name: null
getHtml: ->
this.generateHtml(widgetHtml)
Upvotes: 1