发生某些事件后,如何在KO JS中禁用按钮?
在页面上加载表之后,我正在尝试启用禁用按钮。
self.uploadPdfButtonIsEnabled = false;
self.pricingTableRenderedHandler = function (data, stateName) {
self.uploadPdfButtonIsEnabled = true;
//some other irrelevant logic
}
.cshtml文件
<button class="button button--primary" id="uploadPdfsButton" data-bind="click: $root.openPdfUpload, enable: uploadPdfButtonIsEnabled">
<span class="button__text">Upload PDF</span>
</button>
结果,我只能禁用此按钮,并且未启用它。试图调试和输入 pricingtablerenderedhandler , uploadpdfbuttonisenabled 成为True,但该按钮仍然禁用
I'm trying to enable disabled button after I load a table on the page.
self.uploadPdfButtonIsEnabled = false;
self.pricingTableRenderedHandler = function (data, stateName) {
self.uploadPdfButtonIsEnabled = true;
//some other irrelevant logic
}
.cshtml file
<button class="button button--primary" id="uploadPdfsButton" data-bind="click: $root.openPdfUpload, enable: uploadPdfButtonIsEnabled">
<span class="button__text">Upload PDF</span>
</button>
As a result, I only get this button disabled and it is not enabled. Tried to debug and the pricingTableRenderedHandler is entered, uploadPdfButtonIsEnabled becomes true but the button is still disabled
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用可观察的敲除绑定才能自动更新:
You have to use an observable for the knockout binding to be able to update automatically: