我需要帮助
实际上,在我的工作中,我需要在jqgrid中实现spin.js和阻止UI。当我将代码放在同一个文件和函数中时,这是可以的,但是我想从其他JS文件中调用一个方法,并且听到的是我的问题所在。spin.js和块UI启动,然后取消块阻止UI停止,但spin.js仍在运行。
这是我的代码:
在jqgrid中的BeforeRequest()中,我调用了一个方法
$.pui.common.loaderAnimationON("pane-content");此方法具有以下代码
loaderAnimationON: function (div) {
var opts = {
lines: 13, // The number of lines to draw
length: 20, // The length of each line
width: 10, // The line thickness
radius: 30, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 0, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: '#000', // #rgb or #rrggbb or array of colors
speed: 1, // Rounds per second
trail: 60, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: '50%', // Top position relative to parent in px
left: '50%' // Left position relative to parent in px
};
var target = document.getElementById(div);
var spinner = new Spinner(opts).spin(target);
$.blockUI({
blockMsgClass: "gridProjectsLoader",
message: null
});
return spinner;
},在gridComplete()中,我调用其他方法
$.pui.common.loaderAnimationOFF("pane-content");此方法具有以下代码
loaderAnimationOFF: function (div) {
var target = document.getElementById(div);
var spinner = $.pui.common.loaderAnimationON();
spinner.stop(target);
$.unblockUI();
}有人能帮我吗?
谢谢各位
发布于 2014-04-24 15:50:02
您应该使用同一个对象来启动和停止它。您可以在任何地方使用全局变量(只是另一个.js)检查这个jsFiddle。3秒后停止旋转。
http://jsfiddle.net/YX7dy/8/
spinner=loaderAnimationON('Spin');
setInterval(function(){spinner.stop();},3000);https://stackoverflow.com/questions/23249901
复制相似问题