I have a scenario where the Click event is bind to <tr>
and checked value is bind to checkbox inside the <td?
inside <tr>
. Now the problem is When the row is clicked the event is fired thats fine . But in case of I click the checkbox the observable value changes for row as well and fires the row click event . How to avoid this scenario
<tbody data-bind="foreach:Mails">
<tr data-bind="click:$root.navigateToMail">
<td style="width: 15px">
<input type="checkbox" data-bind="checked: isSelected">
@*<input type="checkbox">*@
</td>
<td data-bind="text: From">
</td>
<td data-bind="text: To">
</td>
<td data-bind="text: Subject">
</td>
<td data-bind="text: MailDate">
</td>
</tr>
</tbody>
The events are :
ko.utils.arrayForEach(data.mails, function (mail) {
mail.isSelected = ko.observable(false);
mail.isSelected.subscribe(function (myvalue) {
console.log(myvalue);
});
});
self.navigateToMail = function (mail) {
location.hash = mail.Folder() + '/' + mail.Id();
};
I trimmed of unnecessary codes . Just have put where the problem has occurred .
clickBubble:false
, but I didn't realize I had to explicitly handle the click event. Sort of thought the checked binding would cover it. – Evangelize