Reapply bindings in knockout

后端 未结 3 1466
名媛妹妹
名媛妹妹 2021-01-12 04:56

I basically want to reapply bindings on the same page for the different objects, but there is strange behavior. After I reapply the binding, the list of items is lost.

3条回答
  •  悲哀的现实
    2021-01-12 05:41

    Doing:

    ko.applyBindings(viewModel, $('#somejQObj')[0]);
    

    Works as stated in the comments of @fengd's answer. Currently have a table that is populated by a foreach statement, that has expandable rows that each one has a dynamically added sub-table that is also populated by a foreach statement. After each sub-table is dynamically inserted doing the above sets the bindings for the sub-table and populates the data.

提交回复
热议问题