I was trying to define some reusable code but then ran into problems because methods/properties in the MVVM observable object weren't there.
Take this code for example:
Now if I were to try and use this as an observable object in the following way:
and if I had some HTML that made use of the isEditing, or toggleEditMode property/method:
it wouldn't work, or rather isn't working.
Is this because kendo is replacing my Object's prototype with it's own ObservableObject?
Regards,
Jacques
Take this code for example:
var
editableModel =
function
()
{
this
.isEditing =
false
;
};
editableModel.prototype.toggleEditMode =
function
(e)
{
this
.set(
"isEditing"
, !
this
.isEditing);
e.stopPropagation();
};
var
individualClient =
function
()
{
this
.clientCode =
""
;
this
.initials =
""
;
this
.title =
""
;
this
.dateOfBirth =
""
;
this
.language =
""
;
};
individualClient.prototype =
new
editableModel();
Now if I were to try and use this as an observable object in the following way:
var
viewModel =
new
individualClient();
viewModel.clientCode =
"ABS"
;
viewModel.initials =
"JA"
;
...
//set the rest of the properties
kendo.bind($(
".binding-container"
),viewModel);
and if I had some HTML that made use of the isEditing, or toggleEditMode property/method:
<
a
href
=
"#"
onclick
=
"viewModel.toggleEditMode()"
>Edit</
a
>
<!--NOTE: This hyperlink is not located inside the binding-container which is why I'm calling it as I am, using the onclick event and the qualified object name -->
<
span
data-bind
=
"text: clientCode, invisible: isEditing"
>@Model.ClientCode</
span
>
it wouldn't work, or rather isn't working.
Is this because kendo is replacing my Object's prototype with it's own ObservableObject?
Regards,
Jacques