I have a model something like this derived from ObservableObject.
Please ignore the syntax as I am just quickly typing this in.
viewModel {
data: {
filter: {
Rows: [{Field: "Hello"}]
}
},
fieldChanged: function() {
}
}
I bind to the Row array items manually like this, I cannot bind to the template directly because I cannot have the template re-render the items when a change is done to the model.
var $tbody = $("table tbody", $fd);
var tmp = kendo.template($("#filtering-row-template").html());
for (var i = 0; i < this.data.filter.Rows.length; i++) {
var row = this.data.filter.Rows[i];
var $r = $(kendo.render(tmp, [row]));
$tbody.append($r);
kendo.bind($r, row);
}
<script type="text/x-kendo-template" id="filtering-row-template">
<tr id="#= uid #">
<td>
<input class="field" data-role="dropdownlist" data-text-field="Name" data-value-field="ID"
data-bind="source: fields, value: Field, events: {change: fieldChanged}" />
</td>
</tr>
</script>
Everything works when I do this except it does not find the fieldChanged function in the root object at runtime.I thought it was supposed to walk up the object chain looking for a match. In the Browsers debugger I can do row.parent().parent().parent().parent() and find the fieldChanged function.