I'm trying to ask a question about async knockout.js validation running on page load, and I'm attempting to reproduce the issue on jsfiddle.
Thing is, I can't get the most basic example to work, despite having a more complex scenario running on my box. What's wrong with this?
http://jsfiddle.net/C5rSm/4/
I have to post code:
<div id="vm">
<input type="text" data-bind="value: validatableField" />
<p data-bind="validationMessage: validatableField"></p>
<button data-bind="click: alertValue">value is alerted ok, but doesn't validate</button>
</div>
var Vm = function(){
var self = this;
self.validatableField = ko.observable().extend({ equal: 2 });
self.alertValue = function(){
alert(self.validatableField());
};
};
ko.applyBindings(new Vm(), document.getElementById('vm'));
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…