I'm using Coffeescript's classes in my view models and am having issues creating ko.computed values. Specifically, the value of 'this' inside of the passed function is always set to Window, not the instance of my Coffeescript class. I've tried passing 'this' as the second parameter to the computed function, but it hasn't worked. Has anyone done this successfully?
Thanks for any help. Coffeescript has worked quite well thus far, with the exception of this one issue.
My CS class looks something like:
window.Section = class Section
constructor: ->
@options = ko.observableArray ['One', 'Two', 'Three']
options: {}
getComputed: ko.computed ->
# I need access to the instance options here
return @options
// My ViewModel, in JS
var viewModel = {
sections: ko.observableArray()
}
viewModel.sections.push(new Section());