Please refer to: https://github.com/Knockout-Contrib/Knockout-Validation
self.userName = ko.observable("").extend({ required: true });
unction LoginViewModel(app, dataModel) { // Private state var self = this, validationTriggered = ko.observable(false); // Private operations function initialize() { dataModel.getExternalLogins(dataModel.returnUrl, true /* generateState */) .done(function (data) { self.loadingExternalLogin(false); if (typeof (data) === "object") { for (var i = 0; i < data.length; i++) { self.externalLoginProviders.push(new ExternalLoginProviderViewModel(app, data[i])); } } else { self.errors.push("Unbekannter Fehler."); } }).fail(function () { self.loadingExternalLogin(false); self.errors.push("Unbekannter Fehler."); }); } // Data self.userName = ko.observable("").extend({ required: true }); self.password = ko.observable("").extend({ required: true }); self.rememberMe = ko.observable(false); self.externalLoginProviders = ko.observableArray(); self.validationErrors = ko.validation.group([self.userName, self.password]); // Other UI state self.errors = ko.observableArray(); self.loadingExternalLogin = ko.observable(true); self.loggingIn = ko.observable(false); ...
Afte some CTRL-H search through the template's code it seems that there is no custom ko.extenders - instruction set found. According to the knockout.js tutorial it is possible to create custom extender functionality:
http://knockoutjs.com/documentation/extenders.html
Keine Kommentare:
Kommentar veröffentlichen