我正在尝试在等待慢速链接时显示某种加载器:
<a href="/api/action/that/takes/some/time" data-bind="click: showLoading">
this.showLoading = function () {
// Display loader while waiting for the redirect
}
click
似乎覆盖了实际链接。有办法解决这个问题吗?
澄清编辑:
我可以做这样的事情,但我更喜欢将网址保留在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;
};
答案 0 :(得分:4)
您只需要return true
处理程序click
触发浏览器的默认操作:
this.showLoading = function () {
// Display loader while waiting for the redirect
return true;
}
在文档中也可以看到它:Allowing the default click action