KendoUI>Framework>MVVM>Bindings

HTML4属性绑定例子:

<img id="logo" data-bind="attr: { src: imageSource, alt: imageAlt }" />
<script>
    
var viewModel = kendo.observable({
        imageSource: 
"http://www.kendoui.com/image/kendo-logo.png",
        imageAlt: 
"Kendo Logo"
    });

    kendo.bind($(
"#logo"), viewModel);
</script>
    

绑定显示结果:

<img id="logo" src="http://www.kendoui.com/image/kendo-logo.png" alt="Kendo Logo"/>

 

HTML5属性绑定例子:

<div data-bind="attr: { data-foo: fooValue, data-bar: barValue }"></div>
<script>
    
var viewModel = kendo.observable({
        fooValue: 
"foo",
        barValue: 
"bar"
    });

    kendo.bind($(
"div"), viewModel);
</script>
    

 

posted @ 2012-04-05 14:29  草珊瑚  阅读(562)  评论(0编辑  收藏  举报