0
我在淘汰賽中獲得了以下代碼。在HTML是如何通過knockout.js獲取文本框onchange的值
<p id="inputField">
What do you want to search?:
<input data-bind="
textInput: searchLocation,
event: {focus: focusHandler}"/>
</p>
視圖模型是
function NeighborhoodModel() {
var self = this;
self.focusHandler = function(){
console.log("focus self.searchLocation "+searchLocation());
};
self.searchLocation= ko.observable("");
searchLocation = ko.observable("");
self.locations = ko.observableArray([]);
self.nameLocation = ko.observable(" ");
console.log(" begin model");
console.log("model self.searchLocation "+searchLocation());
};
ko.applyBindings(new NeighborhoodModel());
如何恢復searchLocation的價值?
消息控制檯是
開始模型
project5.js:15模型self.searchLocation
project5.js:6的焦點self.searchLocation