HI
Is it possible to use DX MVC controls with knockout.js- I am trying to use knockout to read/write a DX control.
How do i "data-bind" to a dev express control??
Something akin to the code below
if you come across this question from a search please note -- SAMPLE CODE AT BOTTOM OF POST WORKS --
JavaScriptscript src="~/Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<script src="~/Scripts/knockout-2.2.1.js" type="text/javascript"></script>
<script>
$(document).ready(function () {
// Here's my data model
var ViewModel = function (first, last) {
this.firstName = ko.observable(first);
this.lastName = ko.observable(last);
this.<bold>DevXTextField</bold>= ko.observable();
this.fullName = ko.computed(function () {
// Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName.
return this.firstName() + " " + this.lastName() + " " + this.<bold>DevXTextField</bold>;
}, this);
};
ko.applyBindings(new ViewModel()); // This makes Knockout get to work
});
</script>
HTML<div class='liveExample'>
<p>First name: <input data-bind='value: firstName' /></p>
<p>Last name: <input data-bind='value: lastName' /></p>
<h2>Hello, <span data-bind='text: fullName'> </span>!</h2>
</div>
<div id="HireContent">
@Html.DevExpress().TextBoxFor(model => model.DevXTextField,
settings => {
settings.Name = "<bold>DevXTextField</bold>";
settings.ShowModelErrors = true;
settings.ControlStyle.CssClass = "editor"; settings.WHATEVER = ("<bold>data-bind</bold>", "<bold>value</bold>: <bold>DevXTextField</bold>");
}).GetHtml()</td>
<td>@Html.ValidationMessageFor(model => model.<bold>DevXTextField</bold>)</td>
What setting on the DX control should i be using in order to data-bind ?Thanks in advance.