jQuery的$(形式).submit()没有触发IE浏览器只(MVC3应用程序) [英] jQuery's $(form).submit() not firing for IE only (MVC3 app)

查看:149
本文介绍了jQuery的$(形式).submit()没有触发IE浏览器只(MVC3应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在网上淘(包括SO),我无法找到任何东西来帮助我与我的情况,所以希望我可以从你们那里得到一些帮助。

I've been scouring the internet (including SO), and I can't find anything to help me out with my situation, so hopefully I can get some help from you guys.

基本上,就像标题所说,.submit()不是在IE中射击。所有其他浏览器工作正常,但在IE(8,9,10,到目前为止),它只是不火的提交。

Basically, like the title says, the .submit() is NOT firing in IE. All other browsers work fine, but in IE (8, 9, 10 so far) it just doesn't fire the submit.

这里的景色code:

        <form id="@formId" method="post" enctype="multipart/form-data" action="@Url.Content("/ActivityEvent/SubmitCheckpointApproval")">
            <table id="checkpoint-approval" style="width:100%" align="center" class="noBorders">
                <tr>
                    <td style="width: 520px;">
                        <div>
                            Please enter any relevant comments:
                        </div>
                        <div style="margin: 10px 0;">
                            <textarea class="wysiwygSimple" rows="4" cols="60" name="comment" id="checkpoint-comment-@(actTplId)"></textarea>
                        </div>
                    </td>
                    <td style="border: 0; padding-top: 30px; text-align: center; width:70px;">
                        <img alt="key" src="/Content/Images/checkmarkInCircle.png" align="middle" style="width: 100px;
                            height: 100px;" /><br />
                        <p style="text-align: left; margin-top: 10px;">
                            The notes and resources entered here are shared with the student.</p>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="ResourcesUploadList">
                        Suggest some resources:<br />
                        <div style="float: left;">
                            <input class="Multi" type="file" name="resourceFiles[]" /></div>
                        <div style="float: left; margin-left: 10px; font-style: italic;">
                            (click browse for each file you want to upload)</div>
                        <div style="clear: both;">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td style="border: 0; text-align: center; width:600px;" colspan="2">
                        @if (hasAdminRights)
                        {
                            <input type="button" @Html.Raw(btnStyle) class="activityApprove" name="actionApprove" id="actionApprove" value="Tutor Completion Approval" title = "Approves all activities preceding this checkpoint as complete." onclick="Activity.submitCheckpointApproval('@(formId)', '@(ActivityEvent.EVENT_TYPE_APPROVED)',@(actTplId));" />
                            <input type="button" @Html.Raw(btnStyle) class="activityAttention" name="actionAttention" id="actionAttention" value="Needs Attention" title = "Notifies the student that this project needs additional work prior to completion." onclick="Activity.submitCheckpointApproval('@(formId)', '@(ActivityEvent.EVENT_TYPE_NEEDS_ATTENTION)',@(actTplId));" /> 
                        }
                        <input type="button" @Html.Raw(btnStyle) value="Cancel" title = "Close this." onclick="javascript:$('#checkpoint-approval@(actTplId)').toggle();" />
                    </td>
                 </tr>
            </table>
        </form>

当按钮被点击:

Activity = {

submitCheckpointApproval: function (formId, activityEventStatusId, activityTemplateId) {
    var resultsDivId = $("#checkpointResults" + activityTemplateId);
    Activity.showCheckpointLoading(resultsDivId); //Just shows a spinner for loading
    $("#checkpoint-activityEventStatusId-" + activityTemplateId).val(activityEventStatusId);
    $("#" + formId).submit(); //PROBLEM IS HERE??
},
...
};

最后,控制器:

    [HttpPost]
    [ValidateInput(false)]
    public ActionResult SubmitCheckpointApproval()
         //Save everything in here
    }

当在IE调试,我可以在JS的.submit()线,并从那里运行它。在此之前,一切都工作得很好,但随后的.submit()来了,停止做任何事情。没有JavaScript错误,没有在控制台上,没有在所有的任何问题迹象。
在所有其他浏览器中,.submit()触发蛮好的,控制器闯入该方法被调用。

When debugging in IE, I get to the .submit() line in the js, and run it from there. Everything before that works just fine, but then the .submit() comes and it stops doing anything. No javascript errors, nothing in the console, no indication of any issues at all. In all other browsers, the .submit() fires just fine, and the controller breaks into the method being called.

有什么想法,为什么这是在IE中发生了什么?我敢肯定,之前有人已经碰到过这样的!请帮帮忙,我整个下午都在敲打我的头我的办公桌上!

Any thoughts as to why this is happening in IE? I'm sure someone has come across this before!! Please help, I've been banging my head off my desk all afternoon!

谢谢你们!

推荐答案

您可能最适合使用jQuery中的 $。触发器()函数来试试。

You might be best suited to try using the $.trigger() function in jQuery.

同样调用它在被呼叫 .submit()的方式:

Invoke it similarly to the way you are calling .submit():

$('#' + formId).trigger('submit');

祝你好运!

同时

有在IE中的漏洞,其中的形式将不能正常提交如果没有

There is a bug in IE where the form will not submit properly if there is no

 <input type="submit" value="Submit" /> element. 

尝试添加一个与CSS隐藏它。

Try adding one and hiding it with CSS.

这篇关于jQuery的$(形式).submit()没有触发IE浏览器只(MVC3应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆