我的申请基于淘汰赛,对我来说最大的障碍如下:
有任何线索吗?
这是代码: 父文件(在头下):
<script type="text/javascript" src="Scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="Scripts/jquery-ui-1.8.20.min.js"></script>
(在体下)
<iframe src="IframePage.html" width="100%" height="100%" id="popUpIframe" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto"></iframe>
iframe文件:
<script type="text/javascript">
var $ = parent.$;
var ko = parent.ko;
$(document).ready(function () {
var ViewModel = function (first, last) {
this.firstName = ko.observable(first);
this.lastName = ko.observable(last);
this.fullName = ko.computed(function () {
alert(this.firstName() + " " + this.lastName());
return this.firstName() + " " + this.lastName();
}, this);
};
ko.applyBindings(new ViewModel("Kawal", "Babra"));
});
</script>
<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>
<h2>Hello, <span data-bind="text: fullName"> </span>!</h2>
答案 0 :(得分:0)
只需将根元素指定为iframes文档中的元素,例如:
ko.applyBindings(Model, document.body)
;
以下是一个有效的例子:http://jsfiddle.net/rD8uR/
以下是iframe文档:http://fiddle.jshell.net/KkPdE/show/light/