Hi,
Is there a way enable two way binding on template referenced in MVVM binding context. I am looking to bind value of radio button to the value of the View Model.
Thanks
Is there a way enable two way binding on template referenced in MVVM binding context. I am looking to bind value of radio button to the value of the View Model.
Thanks
<
form
id
=
"my-form"
class
=
"k-content"
>
<
ul
id
=
"pb"
data-expand-mode
=
"single"
data-role
=
"panelbar"
>
<
li
class
=
"k-state-active"
>
<
span
class
=
"k-link k-state-selected"
>Step 1</
span
>
<
div
class
=
"k-content"
>
<
div
data-bind
=
"text:name"
></
div
>
<
ul
data-template
=
"row-template"
data-bind
=
"source: Reports"
>
</
ul
>
</
div
>
</
li
>
</
ul
>
</
form
>
<
div
id
=
"view-model-state"
></
div
>
<
script
id
=
"row-template"
type
=
"text/x-kendo-template"
>
<
li
><
span
data-bind
=
"text:Name"
></
span
><
input
name
=
"report"
type
=
"radio"
data-bind
=
"value:Value"
/></
li
>
</
script
>
MyApp.Ds =
new
function
() {
var
self =
this
;
self.Reports = [
{Name:
"R1"
, Value: 1},
{Name:
"R2"
, Value: 2},
{Name:
"R3"
, Value: 3},
];
};
MyApp.ViewModel = (
function
(){
var
vm = kendo.observable({
name:
"Nested Template Test"
,
Reports: MyApp.Ds.Reports,
Report:
""
});
vm.bind(
"change"
,
function
(e) {
$(
"#view-model-state"
).html(JSON.stringify(vm.toJSON()));
//console.log("change", vm.toJSON());
});
vm.bind(
"set"
,
function
(e) {
$(
"#view-model-state"
).html(JSON.stringify(vm.toJSON()));
//console.log("set", vm.toJSON());
});
return
vm;
})();
$(
function
() {
kendo.bind($(
"#my-form"
), MyApp.ViewModel);
});