我想在bootboxjs警報中訪問我的knockout js viewmodel。你知道我的代碼爲什麼不起作用嗎?如何在bootbox警報中訪問基因敲除變量/ observables
的jsfiddle:https://jsfiddle.net/bt2pffcd/1/
簡化代碼:
<div class="bootbox">
<input data-bind="textinput: testText"/> Typed:
<label data-bind="text: testText"></label>
</div>
<button data-bind=" click: bootBox">Launch bootbox!</button>
我的視圖模型和applybindings:
var ViewModel = function() {
var self = this;
self.testText = ko.observable("Test");
self.bootBox = function() {
bootbox.alert($("div.bootbox").html());
}
}
ko.applyBindings(new ViewModel());
你的jsfiddle有錯誤。看看控制檯 –
我看着它,但它不是這裏的麻煩製造者我確信那個 – Developerdeveloperdeveloper
我更新了你的[小提琴](https://jsfiddle.net/bt2pffcd/2/)與不同版本的淘汰賽和重新排序外部資源 - 你問你爲什麼bootbox警報中的文本框沒有被填充? – Forty3