So, I'm trying to add a class to an element using Knockout.js based on checking the child checkbox. For this, I am trying to pass this
as an argument to my function. Currently, my shortened DOM structure is as follows:
<tr data-bind="css: { selected: isRowChecked(this) }"> <td><label><input type="checkbox"></label></td> </tr>
My isRowChecked
function is this (I use jQuery to search for input):
function isRowChecked(elem) { var checkbox = $(elem).find('input[type="checkbox"]'); return checkbox.checked; }
However, if I console.log
elem
all I get is a global window object.
It is impossible to use jQuery to completely solve this problem, because the project I'm working on already uses knockout almost exclusively. Any ideas?
source share