I am trying to populate an HTML5 table using Knockout.js. Populating the table works great, until I try to make each table row a "link" to the entity the row is about. In particular, my HTML5 looks like:
<tr class="collection-row" data-bind="attr: { 'data-url': itemUrl }">
<td data-bind="text: view.date">
<td data-bind="text: view.title">
<td data-bind="text: view.author">
The idea being that the tr should end up with a data-url attribute which points at itemUrl (a computed observable). I hoped that I would be able to do something along the lines of:
$(".collection-row").click(function(){
window.location.href = $("this").data("url");
});
to turn the whole row into a "link" to itemUrl. This works great, except that it doesn't at all. When I click, I get sent to /admin/undefined. I can confirm that the itemUrl observable is returning the correct URL. So it looks like jQuery can't see Knockout's data-url attribute binding. How should I proceed?
onto set the click binding. Maybe theclickbinding is being registered on the DOM element before Knockout has finished all the bindings - rwisch45