【发布时间】:2013-07-16 15:23:20
【问题描述】:
我创建了一个启动活动指示器的方法和一个停止给定指示器的不同方法。然后在做一些耗时的任务时,我会先调用 start 方法,然后调用 stop 方法。调用示例如下所示:
// Show loading
viewControllerShowAjax();
// Tasks that take time including large calculations and ajax requests
app.timeConsumingFunction();
// Hide loading
viewControllerHideAjax();
这是适用于 firefox,但不适用于 IE 或 Chrome。有解决办法吗?
编辑: 以下是我正在使用的功能:
function viewControllerInit() {
// Other initializations
...
// Initializing the activity indicator; the activity indicator is simply a jqueryui modal view with a spinjs spinner in it.
$(this.ajaxModalSelector).dialog({
resizable : false,
dialogClass : "no-close ajax",
autoOpen : false,
height : 500,
width : 500,
modal : true,
open: function( event, ui ) {
$(this.ajaxModalSelector).dialog("open");
var opts = {
lines: 12,
length: 0,
width: 20,
radius: 40,
color: '#000',
speed: 1.3,
trail: 50,
shadow: false,
};
this.spinner = new Spinner(opts).spin(document.getElementById("ajax-modal"));
},
beforeClose: function( event, ui ) {
this.spinner.stop();
}
});
}
// Opens the jquery ui modal view
function viewControllerShowAjax() {
$(this.ajaxModalSelector).dialog("open");
}
// Closes the jquery ui modal view
function viewControllerHideAjax() {
$(this.ajaxModalSelector).dialog("close");
}
编辑:有关问题的更多信息;我发现如果没有为活动指示器调用隐藏函数,那么它会在耗时任务完成后出现。同样,这是 IE 和 Chrome 中的行为,但不是 firefox。
【问题讨论】:
-
您需要提供有关“活动指标”的更多信息。它如何具体表明活动?
-
这完全取决于这些函数的作用。
-
您能否发布一些这些函数的代码,以便我们更好地帮助您?或者更有帮助的是有一个 jsfiddle 示例
-
There is no way this works in Firefox either。也许您正在测试缓存代码或其他东西? async jsfiddle
-
@Esailija 它确实适用于 firefox,但我不知道为什么会这样,为什么它在 chrome 或 ie 上都不起作用?我应该以其他方式执行此操作吗?
标签: javascript jquery internet-explorer google-chrome cross-browser