jQuery 块 UI - 在 X 时间后用 "Still working..." 更新 "Please wait..." 消息
jQuery Block UI - Updating "Please wait..." message with "Still working..." after X amount of time
我在文档中找不到关于如何为长 运行 进程更新块 UI 文本的信息。例如,根据所选选项保存对表单的更改将触发各种过程,其中一些过程可能需要一些时间。我希望初始块 ui 消息说 "Processing..." 然后在 15 秒后说 "Still working..." 这样用户就不会认为页面超时。我已经在 gmail 中看到了这一点,并希望复制该功能。有适合这个的gui舞蹈吗?
可能对您有帮助的是 setTimeout
. It allows you to run some code after N milliseconds. There's a matching function, clearTimeout
,它将 "remove" 来自队列的 setTimeout
处理程序。
使用这些工具,您可以构建与此类似的代码:
var timeoutID;
function startBlocking() {
// do your stuff...
$.blockUI({ message: "Processing..." });
timeoutID = setTimeout(function() {
$.blockUI({ message: "Still working..." });
}, 15000);
}
function stopBlocking() {
// This is called whenever your processing is done
clearTimeout(timeoutID);
}
有了这个,只有当进程没有完成时,消息才会在 15 秒后改变。当它完成时,它有效地防止 $.blockUI({ message: "Still working..." })
来自 运行.
我在文档中找不到关于如何为长 运行 进程更新块 UI 文本的信息。例如,根据所选选项保存对表单的更改将触发各种过程,其中一些过程可能需要一些时间。我希望初始块 ui 消息说 "Processing..." 然后在 15 秒后说 "Still working..." 这样用户就不会认为页面超时。我已经在 gmail 中看到了这一点,并希望复制该功能。有适合这个的gui舞蹈吗?
可能对您有帮助的是 setTimeout
. It allows you to run some code after N milliseconds. There's a matching function, clearTimeout
,它将 "remove" 来自队列的 setTimeout
处理程序。
使用这些工具,您可以构建与此类似的代码:
var timeoutID;
function startBlocking() {
// do your stuff...
$.blockUI({ message: "Processing..." });
timeoutID = setTimeout(function() {
$.blockUI({ message: "Still working..." });
}, 15000);
}
function stopBlocking() {
// This is called whenever your processing is done
clearTimeout(timeoutID);
}
有了这个,只有当进程没有完成时,消息才会在 15 秒后改变。当它完成时,它有效地防止 $.blockUI({ message: "Still working..." })
来自 运行.