Knockout and data tables

I am trying to use DataTables with knockout generated table.

The problem is illustrated here: http://jsfiddle.net/sQrNu/

In my table I have a series of fixed column headers as well as several column headers that are from the view model. This works great with standard knockout HTML table.

However, when the dataTable widget is applied to a table, the dynamic columns become a simple column with the text "[object Object]". It seems that after the dataTables was applying templated breaks. If I replace the template:

data-bind = "text: $ data"

FROM

data-bind = "text: JSON.stringify ($ data)"

Then I find that all of a sudden $ data is now mistakenly referring to my root view model; "foreach: headers" no longer works.

Is this a knockout mistake?

+3


source to share


1 answer


Add setTimeout to let the DOM complete the update before trying to attach the dataTable.



http://jsfiddle.net/jearles/sQrNu/1/

+3


source







All Articles