我正在尝试创建一个简单的进度小部件。但我得到_showProgress
的不是一次又一次的函数错误。
(function ($, undefined) {
$.widget("AOne.ProgressBar", {
options: { max: 100, min: 0, current: 0, time: 1000, stepWidth: 1 },
innerDiv: $("<div></div>").css({ overflow: 'hidden', clear: 'both',
height: '10px', width: '0px',
background: 'transparent url("Progress.gif") repeat-x
scroll left center' }).html(" "),
_create: function () {
this.element.append(this.innerDiv);
maxWidth = this.element.outerWidth();
this.options.stepWidth = maxWidth / this.options.max;
},
_init: function () {
this.intervalId = setInterval(function () {
this._showProgress();
},
this.options.time);
},
_showProgress: function () {
this.options.current += 1;
if (this.options.current < this.options.max) {
this.innerDiv.css({ width: this.options.stepWidth *
this.options.current + 'px' });
} else {
window.clearInterval(this.intervalId);
}
},
_setOption: function (key, value) {
$.Widget.prototype._setOption.apply(this, arguments);
},
destroy: function () {
$.Widget.prototype.destroy.call(this);
}
});
})(jQuery);