简体   繁体   English

jQuery对话框/ Submit()在IE8中不起作用

[英]JQuery dialog / submit() not working in IE8

Works everywhere except IE8. 除了IE8之外,其他任何地方都可以使用。 The submit never fires. 提交者从不解雇。 I tried taking out the dialog and just leaving the submit but still nothing happens in IE8. 我试着退出对话框,只留下提交,但在IE8中仍然没有任何反应。

Javascript: Javascript:

$(function () {
    $("#fileUpload").click(function () {
        $("#fileButton").click();
    });
});

$(function () {
    $("#fileButton").change(function () {
        $("#dialogUploading").dialog({
            dialogClass: 'no-close',
            modal:true,
            async:true
        });
        $("#formSubmit").submit();
    });
});

HTML: HTML:

        using (Html.BeginForm("ReferralUpload", "ReferralNetwork", FormMethod.Post, new { enctype = "multipart/form-data", id = "formSubmit", style = "display:inline" }))
        {
            <input type="file" id="fileButton" name="fileButton" style="display:none" />
            <button type="button" id="fileUpload" style="width:250px;">Upload Referrals</button>
        }

Any ideas? 有任何想法吗? Thanks! 谢谢!

can you try changing $("#fileButton").change(function () { to $("#fileButton").change(function (e) { and see if that makes a difference? I think IE needs the event passed for it to be happy. 您可以尝试将$("#fileButton").change(function () {$("#fileButton").change(function (e) { ,看看是否有区别吗?我认为IE需要传递事件要开心。

Oh, and do the same for $("#fileUpload").click(function () { to $("#fileUpload").click(function (e) { 哦,对$("#fileUpload").click(function () {$("#fileUpload").click(function (e) {

Make sure you're using the correct version of jQuery. 确保您使用的是正确版本的jQuery。 Version 2 and above aren't compatible with IE8. 版本2及更高版本与IE8不兼容。

http://jquery.com/browser-support/ http://jquery.com/browser-support/

After further research, I discovered it can't be done jQuery : simulating a click on a <input type="file" /> doesn't work in Firefox? 经过进一步的研究,我发现它无法完成jQuery:模拟<input type =“ file” />的单击在Firefox中不起作用? . Not without some hackery. 并非没有黑客。 In IE8 the file input can't be programatically clicked or it won't submit. 在IE8中,无法以编程方式单击文件输入,否则将无法提交。 One hack is to set the opacity to zero and have an image over the button: http://www.quirksmode.org/dom/inputfile.html 一种技巧是将不透明度设置为零,并在按钮上放置一个图像: http : //www.quirksmode.org/dom/inputfile.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM