Kendo UI开发教程(20): Kendo MVVM 数据绑定(九) Text
2014-01-21 09:15
513 查看
Text绑定可以使用ViewModel来设置DOM元素的文本属性,如果需要设置input,textarea,或select的显示,需要使用value属性。
本例输出:
John Doe
如果ViewModel的值包含html标记,这些标记会直接显示出html标记,比如:
如果需要以粗体显示,则可以使用前面介绍的html绑定。
Text绑定可以使用ViewModel来设置DOM元素的文本属性,如果需要设置input,textarea,或select的显示,需要使用value属性。
1 | < span data-bind = "text: name" ></ span > |
2 | < script > |
3 | var viewModel = kendo.observable({ |
4 | name: "John Doe" |
5 | }); |
6 |
7 | kendo.bind($("span"), viewModel); |
8 | </ script > |
John Doe
如果ViewModel的值包含html标记,这些标记会直接显示出html标记,比如:
1 | < span data-bind = "text: name" ></ span > |
2 | < script > |
3 | var viewModel = kendo.observable({ |
4 | name: "< strong >John Doe</ strong >" |
5 | }); |
6 |
7 | kendo.bind($("span"), viewModel); |
8 | </ script > |
如果需要以粗体显示,则可以使用前面介绍的html绑定。
相关文章推荐
- Kendo UI开发教程(20): Kendo MVVM 数据绑定(九) Text
- Kendo UI开发教程(20): Kendo MVVM 数据绑定(九) Text
- Kendo UI开发教程(22): Kendo MVVM 数据绑定(十一) Value
- Kendo UI开发教程(14): Kendo MVVM 数据绑定(三) Click
- Kendo UI开发教程(21): Kendo MVVM 数据绑定(十) Source
- Kendo UI开发教程(12): Kendo MVVM 数据绑定(一) attr
- Kendo UI开发教程(15): Kendo MVVM 数据绑定(四) Disabled/Enabled
- Kendo UI开发教程(15): Kendo MVVM 数据绑定(四) Disabled/Enabled
- Kendo UI开发教程(21): Kendo MVVM 数据绑定(十) Source
- Kendo UI开发教程(16): Kendo MVVM 数据绑定(五) Events
- Kendo UI开发教程(13): Kendo MVVM 数据绑定(二) Checked
- Kendo UI开发教程(14): Kendo MVVM 数据绑定(三) Click
- Kendo UI开发教程(22): Kendo MVVM 数据绑定(十一) Value
- Kendo UI开发教程(16): Kendo MVVM 数据绑定(五) Events
- Kendo UI开发教程(15): Kendo MVVM 数据绑定(四) Disabled/Enabled
- Kendo UI开发教程(12): Kendo MVVM 数据绑定(一) attr
- Kendo UI开发教程(16): Kendo MVVM 数据绑定(五) Events
- Kendo UI开发教程(17): Kendo MVVM 数据绑定(六) Html
- Kendo UI开发教程(22): Kendo MVVM 数据绑定(十一) Value
- Kendo UI开发教程(12): Kendo MVVM 数据绑定(一) attr