仪表板:通过更改按钮标签提供用户反馈
我想要的是通过按钮标签向用户提供有关操作状态的反馈。 最初按钮显示“保存”,单击后我想将标签更改为“保存...”,输入另一个函数,函数返回后将标签更改为“已保存”,然后暂停 2 秒并再次将标签设置为初始“保存”值。
这是代码:
function myClickHandler(event)
{
document.getElementById("button").object.textElement.color = "saving...";
functionx ()
document.getElementById("button").object.textElement.color = "saved";
sleep (5000);
document.getElementById("button").object.textElement.color = "save";
}
问题是,由于某种原因,只有最后一个 document.getElementById("button").object.textElement.color = "save";
实际上在画布上可见,因为画布或仅当我退出 myClickHandler 函数时才会呈现按钮。 有什么提示吗?
提前致谢
What I want is to provide user feedback about operation status through button label.
Initially the button says "save", once clicked I want to change the label to "saving..." enter another function and once the function returns change the label to "saved" then pause 2 seconds and set the label again to initial "save" value.
Here is the code:
function myClickHandler(event)
{
document.getElementById("button").object.textElement.color = "saving...";
functionx ()
document.getElementById("button").object.textElement.color = "saved";
sleep (5000);
document.getElementById("button").object.textElement.color = "save";
}
The problem is that for some reason only the last document.getElementById("button").object.textElement.color = "save";
is actually visible on canvas because the canvas or button are rendered only once I exit from myClickHandler
function.
Any hint?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的东西可能会效果更好。我很确定 setTimeout 是非阻塞的。
Something like this might work better. I'm pretty sure setTimeout is non-blocking.