Hello,
I need to incorporate KnockoutJS to the project I'm creating.
I added KnockoutJS to a TextBox and it works!
Here's the code
01.
@{
02.
var xx = Html.Kendo().TextBox()
03.
.Name(
"name11"
);
04.
05.
Dictionary<
string
,
object
> attrs =
new
Dictionary<
string
,
object
>();
06.
07.
attrs.Add(
"data-bind"
,
"textInput: name"
);
08.
09.
xx.HtmlAttributes(attrs);
10.
xx.Render();
11.
}
But when I try to add KnockoutJS to a ComboBox using the same technique it doesn't work. I've tried using Knockout-Kendo v0.9.5 but it doesn't work too :(
Here's my code:
01.
@{
02.
var aa = Html.Kendo().ComboBox()
03.
.Name(
"comboBox_moneda"
)
04.
.DataValueField(
"ID"
)
05.
.DataTextField(
"Product"
)
06.
.BindTo(@Model.Products)
07.
.Filter(FilterType.StartsWith);
08.
09.
var dic =
new
Dictionary<
string
,
object
>();
10.
11.
dic.Add(
"data-binding"
,
"kendoComboBox: { value: selectedChoice }"
);
12.
13.
aa.HtmlAttributes(dic);
14.
15.
aa.Render();
16.
}
Here's my ViewModel for the two code snippets above
1.
var
viewModel = {
2.
name: ko.observable(),
3.
selectedChoice: ko.observable()
4.
};
5.
6.
ko.applyBindings(viewModel);
How can I fix this?
Thank you,
Mike.