TypeScript knockout viewmodel access class instance

Topics: General
Feb 19, 2013 at 8:52 PM
I have a class that is used as a knockout viewmodel.
The class has a function that handles an click event on the view.
Inside this function, "this" refers to the datacontext the clicked item. But I want to access an instance variable of the class, how can this be done ?
I can't use the => operator, because it's knockout that is calling a function.

e.g.
class KnockoutViewModel {
   public Items : KnockoutObservableArray;
   public SelectItem( ) { ... // this referes to the data item click, an item from the Items array }
}
Feb 20, 2013 at 3:24 PM
Perhaps this will work
<button data-bind="click: SelectItem.bind($parent)">
    Click me
</button>
PS: I'd try the knockout Google group - not sure if this is a TypeScript issue.