且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

淘汰赛:可以在不扩展模型的情况下选择表格行吗?

更新时间:2023-09-09 22:55:46

这是我现在的最终解决方案,没有多余的隐藏单选按钮:

This was my final solution now, no extra hidden radio buttons:

<tr data-bind="click: $root.selectProduct, css: { 'active-row': $root.selectedProduct() === $data }">

以及ViewModel中的selectedProduct实现:

And the selectedProduct implementation within the ViewModel:

function AppViewModel() {
    // Private
    var self = this;

    // Public Properties
    self.selectedProduct = ko.observable();