0

我在此示例http://knockoutjs.com/examples/grid.html中使用 durandal 和淘汰赛分页网格创建了一个单页应用程序 。

我的问题是如何获取选定行的值。我尝试了以下步骤,但没有任何反应。在我的视图模型的附加事件中,我有这个命令。

$(view).find('.table tbody>tr').on('click', function (event) {
    $(view).find('.table tbody>tr').addClass('success')
           .siblings().removeClass('success');          
});
4

1 回答 1

1

Durandal samples already has the knockout examples integrated e.g. http://dfiddle.github.io/dFiddle-2.0/#knockout-samples/pagedGrid so that might be a better starting point.

Please take a look at some of the knockout documentation at http://learn.knockoutjs.com to figure out why it's a good idea NOT to use jQuery for things that are better handled in knockout. Especially read about click binding http://knockoutjs.com/documentation/click-binding.html. Once you got your app working that way read http://www.knockmeout.net/2012/11/revisit-event-delegation-in-knockout-js.html and upgrade your solution to use it.

于 2013-10-07T07:21:56.883 回答