需要点击自定义文件上传与jQuery设置VAL()后提交按钮两次 [英] Need to click submit button twice after setting val() with jquery in custom file upload
问题描述
我想要的风格通过隐藏它,并把我自己的控件的ASP.NET FileUpload控件。我用jQuery做这样的:
I'm trying to style an ASP.NET FileUpload control by hiding it and putting in my own controls. I'm doing this with jQuery:
$(function () {
$('input[type=file]').each(function () {
var fileUpload = $(this);
var textBox = $('<input type="text">');
textBox
.css('width', fileUpload.width() - 85)
.css('margin-right', 5)
.prop('disabled', fileUpload.prop('disabled'));
var button = $('<input type="button" value="Browse...">')
.prop('disabled', fileUpload.prop('disabled'));
fileUpload.change(function () {
textBox.val(fileUpload.val());
});
button.click(function () {
fileUpload.click();
});
fileUpload.after(button).after(textBox);
fileUpload.hide();
});
});
这基本上只是我需要点击我在IE(10)两次提交按钮的伟大工程。我不能重现的jsfiddle,但我的确让一个剥离下来ASP.NET项目它发生在哪里。
This basically works great, except that I need to click my submit button twice in IE (10). I can't reproduce this in jsFiddle, but I did make a stripped down ASP.NET project where it happens.
在Firefox中,我没有这个问题。任何人都知道在哪里可以开始看?
In Firefox, I don't have this problem. Anyone know where I can start to look?
推荐答案
没法比的回答<一个href=\"http://stackoverflow.com/questions/16242072/html5-file-upload-form-with-customized-style-cant-fire-submit-button-using-ie10\">this问题解决了为我。也许,这是某种形式的安全特性,我不知道。但是,通过使用标签的文件上传,你只需要点击一次标签。
Fabi's answer to this question solved it for me. Possibly, it's some sort of security feature, I'm not sure. But by using a label for the file upload, you only need to click the label once.
您将不得不虽然样式标签作为一个按钮。有一个在的jsfiddle一个很好的解释。我不知道有关Mozilla上述表示的。它工作正常在Firefox我。
You will have to style the label as a button though. There's a great explanation in the jsFiddle. I'm not sure about the remark about Mozilla. It works fine in Firefox for me.
这篇关于需要点击自定义文件上传与jQuery设置VAL()后提交按钮两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!