Javascript 如果其他绑定无法正常工作,则将其击出
我是新手,现在我遇到了一个奇怪的问题。我想要的是使用Javascript 如果其他绑定无法正常工作,则将其击出,javascript,knockout.js,Javascript,Knockout.js,我是新手,现在我遇到了一个奇怪的问题。我想要的是使用ko如果其他绑定,请参见下面的代码: <table> <thead> something...... </thead> <tbody> <tr> Problem comes here... <!-- ko ifnot: editing --> <td><span data-bind="text: Value" /></td&
ko如果其他绑定
,请参见下面的代码:
<table>
<thead>
something......
</thead>
<tbody>
<tr>
Problem comes here...
<!-- ko ifnot: editing -->
<td><span data-bind="text: Value" /></td>
<td><button data-bind="click: Edit">Edit</button></td>
<!-- /ko -->
<!-- ko if: editing -->
<td><input data-bind="value: Value"></td>
<td><button data-bind="click: Save">Save</button></td>
<!-- /ko -->
</tr>
</tbody>
</table>
当启动页面时,if和ifnot语句中的内容都会显示出来(应该是错误的)。单击“编辑”时,只有if语句中的内容显示,ifnot语句中的内容消失,这很好,但单击“保存”时,if和ifnot语句中的内容全部显示
我不知道我的代码哪部分是错误的,有人能帮我一下吗?谢谢。您必须在viewmodel中添加可观察到的值。将以下行添加到函数设置数据() 你想在这里工作就在这里
function SettingData(){
var self = this;
self.editing = ko.observable(false);
self.Edit = function () {
self.editing(true);
};
self.Save = function () {
self.editing(false);
}
}
self.Value = ko.observable("");