Joe*_*oel 4 javascript jquery knockout.js
我正在尝试在等待慢速链接时显示某种加载程序:
<a href="/api/action/that/takes/some/time" data-bind="click: showLoading">
Run Code Online (Sandbox Code Playgroud)
<a href="/api/action/that/takes/some/time" data-bind="click: showLoading">
Run Code Online (Sandbox Code Playgroud)
在click似乎忽略实际的链接。有没有办法解决这个问题?
澄清编辑:
我可以做这样的事情,但我更愿意将 url 保留在 href 上,只需将showLoading位添加到那些需要一些时间的链接中
<a href="#" data-bind="click: showLoading.bind($data, '/api/action/that/takes/some/time'">
this.showLoading = function(link) {
// Display loader while waiting for the redirect
window.location.href = link;
};
Run Code Online (Sandbox Code Playgroud)
您只需return true要从click处理程序中触发浏览器的默认操作:
this.showLoading = function () {
// Display loader while waiting for the redirect
return true;
}
Run Code Online (Sandbox Code Playgroud)
另请参阅文档:允许默认点击操作
| 归档时间: |
|
| 查看次数: |
4936 次 |
| 最近记录: |