New to Kendo UI for jQuery? Start a free 30-day trial
Bindings
Updated over 6 months ago
A binding pairs a DOM element (or widget) property to a field or method of the View-Model. Bindings are specified via the data-bind attribute in the form <binding name>: <view model field or method>, such as value: name.
The Kendo UI MVVM supports binding to other properties as well: source, html, attr, visible, enabled, and others. The data-bind attribute may contain a comma-separated list of bindings, such as data-bind="value: name, visible: isNameVisible". For more information on each Kendo UI MVVM binding, refer to the MVVM bindings articles.
- Bindings cannot include hard-coded values but only references to properties of the
viewModel. For example, thedata-bind="visible: false, source: [{ foo: 'bar'}]"configuration is incorrect.- The
data-templateattributes cannot contain inline template definitions, but only IDs of external templates.
The Kendo UI MVVM also supports data binding to nested View-Model fields.
html
<div data-bind="text: person.name">
</div>
<script>
var viewModel = kendo.observable({
person: {
name: "John Doe"
}
});
kendo.bind($("div"), viewModel);
</script>