我最近将jquery库更新为3.3.1,此后jquery.fileupload-ui在此处中断
_initEventHandlers: function () {
$.blueimp.fileupload.prototype._initEventHandlers.call(this);
var filesList = this.element.find('.files'),
eventData = { fileupload: this };
filesList.find('.start a')
.live(
'click.' + this.options.namespace,
eventData,
this._startHandler
);
filesList.find('.cancel a')
.live(
'click.' + this.options.namespace,
eventData,
this._cancelHandler
);
filesList.find('.delete a')
.live(
'click.' + this.options.namespace,
eventData,
this._deleteHandler
);
},
我的感觉是live
已过时。
如何修改此代码以解决此问题?
亲切的问候
答案 0 :(得分:2)
您的感觉是正确的,live()
很久以前已过时,已被删除。
现代的方法是使用on()
方法的委托签名。给定您的代码,它看起来像这样:
_initEventHandlers: function() {
$.blueimp.fileupload.prototype._initEventHandlers.call(this);
var filesList = this.element.find('.files'),
eventData = { fileupload: this },
clickEventName = 'click.' + this.options.namespace;
filesList.on(clickEventName, '.start a', eventData, this._startHandler);
filesList.on(clickEventName, '.cancel a', eventData, this._cancelHandler);
filesList.on(clickEventName, '.delete a', eventData, this._deleteHandler);
},