Reputation: 737
I'm having a problem with the knockout.js library. I am using the following code, and the databindings are not executing properly.
HTML Code:
<form data-bind="submit: LogintoSite">UserId:
<input type="email" data-bind="value: UserLogin" />Password:
<input type="password" data-bind="value: Password" />
<button type="submit">Login</Button>
</form>
JavaScript:
var LoginScreenViewModel = function () {
var self = this;
self.UserLogin = ko.observable("Hello");
self.Password = ko.observable("");
self.LoginToSite = function () {
alert("You Pushed the button");
};
};
ko.ApplyBindings(new LoginScreenViewModel());
The project itself is in MVC 4 but i have tried this code on jsfiddle as well and it does not work there either. I can't figure out why it will not work. I am assuming this is something simple i forgot in my code.
Thanks!
Upvotes: 1
Views: 1094
Reputation: 37416
You have LoginToSite
in your viewmodel while in your databindings you have LogintoSite
, notice the lowercase "t".
As somebody else mentioned in the comments I think you should also be calling applyBindings
instead of ApplyBindings
Upvotes: 2