我想在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