我的视图中有一个下拉列表,我想要在我的视图中。我想要在更改我的下拉列表时,一个 java 脚本模板绑定下拉列表。我写这个但不工作恳求帮助我。
var roles=[{
code:1,
roleName: "Admin",
access: [
{ id: 1, description: "create", selected: true},
{id: 2, description: "delete", selected: false},
{ id: 3, description: "update", selected: false}
]
} ,{
code:2,
roleName: "user",
access: [
{ id: 1, description: "create", selected: true},
{id: 2, description: "delete", selected: true},
{ id: 3, description: "update", selected: false}
]
}];
var viewModel = kendo.observable({
Roles:roles,
role:"Admin",
accessRole:null
});
kendo.bind($("#example"), viewModel);
这是我的视图代码
<div id="example">
Current Role :<span data-bind="text: role"></span>
<br>
<select type="text" id="RoleName" data-bind="source: Roles, value:role" data-text-field="roleName">
<select/>
<ul data-template="row-template" data-bind="source: accessRole.access"></ul>
</div>
<script id="row-template" type="text/x-kendo-template">
<li>
<input type="checkbox" data-bind="checked: selected" />
<label data-bind="text: description" />
</li>
</script>
这是在线代码: http: //jsfiddle.net/shahr0oz/K4X3T/19/ </p>