我正在尝试删除C:\fakepath。
这是输入的创建和处理程序的 JavaScript:
Ext.ns("Deluge.add");
Deluge.add.FileWindow=Ext.extend(Deluge.add.Window, {
title: _("Add from File"), layout: "fit", width: 350, height: 115, modal: true, plain: true, buttonAlign: "center", closeAction: "hide", bodyStyle: "padding: 10px 5px;", iconCls:"x-deluge-add-file", initComponent:function() {
Deluge.add.FileWindow.superclass.initComponent.call(this);
this.addButton(_("Add"), this.onAddClick, this);
this.form=this.add({
xtype:"form", baseCls:"x-plain", labelWidth:35, autoHeight:true, fileUpload:true, items:[ {
xtype:"fileuploadfield", id:"torrentFile", width:280, height:24, emptyText:_("Select a torrent"), fieldLabel:_("File"), name:"file", buttonCfg: {
text: _("Browse")+"..."
}
}]
});
}, onAddClick:function(c, b) {
if(this.form.getForm().isValid()) {
this.torrentId=this.createTorrentId();
this.form.getForm().submit( {
url: deluge.config.base+"upload", waitMsg: _("Uploading your torrent..."), failure: this.onUploadFailure, success: this.onUploadSuccess, scope: this
}
);
var a=this.form.getForm().findField("torrentFile").value;
a=a.split("\\").slice(-1)[0];
this.fireEvent("beforeadd", this.torrentId, a)
}
}, onGotInfo:function(d, c, a, b) {
d.filename=b.options.filename;
this.fireEvent("add", this.torrentId, d)
}
, onUploadFailure:function(a, b) {
this.hide();
Ext.MessageBox.show( {
title: _("Error"), msg: _("Failed to upload torrent"), buttons: Ext.MessageBox.OK, modal: false, icon: Ext.MessageBox.ERROR, iconCls: "x-deluge-icon-error"
}
);
this.fireEvent("addfailed", this.torrentId)
}
, onUploadSuccess:function(c, b) {
this.hide();
if(b.result.success) {
var a=b.result.files[0];
this.form.getForm().findField("torrentFile").setValue("");
deluge.client.web.get_torrent_info(a, {
success: this.onGotInfo, scope: this, filename: a
})
}
}
}
这是 HTML:
<form class="x-plain-body x-plain-body-noheader x-form" method="POST" id="ext-gen248" enctype="multipart/form-data" style="height: auto; width: 328px;">
<div class="x-form-item " tabindex="-1" id="ext-gen269">
<label for="torrentFile" style="width:35px;" class="x-form-item-label">Fichier:</label>
<div class="x-form-element" id="x-form-el-torrentFile" style="padding-left:40px">
<div class="x-form-field-wrap x-form-file-wrap" id="ext-gen270" style="width: 280px; height: 24px;">
<input type="text" size="20" autocomplete="off" id="torrentFile" class="x-form-text x-form-field x-form-file-text" readonly="" style="width: 209px;"><input id="torrentFile-file" name="file" class="x-form-file" type="file" size="1">
<table id="ext-comp-1386" cellspacing="0" class="x-btn x-form-file-btn x-btn-noicon" style="width: auto;">
<tbody class="x-btn-small x-btn-icon-small-left">
<tr>
<td class="x-btn-tl"><i> </i></td>
<td class="x-btn-tc"></td>
<td class="x-btn-tr"><i> </i></td>
</tr>
<tr>
<td class="x-btn-ml"><i> </i></td>
<td class="x-btn-mc"><em class="" unselectable="on"><button type="button" id="ext-gen271" class=" x-btn-text">Parcourir...</button></em></td>
<td class="x-btn-mr"><i> </i></td>
</tr>
<tr>
<td class="x-btn-bl"><i> </i></td>
<td class="x-btn-bc"></td>
<td class="x-btn-br"><i> </i></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</form>
我试图在输入更改但没有成功时获取事件。
我尝试了什么:
$('#torrentFile-file').change(function(){
alert('ok');
})
和:
$('#torrentFile-file').on('change', function() {
alert('ok');
});