我正在尝试删除 C:\ fakepath 。
以下是创建和处理输入的JavaScript:
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css" />
<script src="https://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>
</head>
<body>
<div class="variants" style="cursor:pointer;border:1px solid #CDCDCD;width:192px; height:223px;float:left;">
test
</div>
<div class="variants" style="cursor:pointer;border:1px solid #CDCDCD;width:192px; height:223px;float:left;">
test
</div>
<div class="variants" style="cursor:pointer;border:1px solid #CDCDCD;width:192px; height:223px;float:left;">
test
</div>
<div class="variants" style="cursor:pointer;border:1px solid #CDCDCD;width:192px; height:223px;float:left;">
test
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.variants').slick({
infinite: true,
slidesToShow: 2,
slidesToScroll: 2
});
});
</script>
</body>
</html>
这是HTML:
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
})
}
}
}
当输入更改但没有成功时,我试图获取事件。
我尝试过的事情:
<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');
})
答案 0 :(得分:0)
我只是想通了。这是我的方法:
$(document.body).on('change',"#torrentFile-file",function (e) {
var path = $('#torrentFile-file').val();
var filename = path.replace(/^.*\\/, "");
$('#torrentFile').val(filename);
});