我一直在搜索互联网(包括SO),我找不到任何可以帮助我解决问题的方法,所以希望我能得到你们的帮助.
基本上,就像标题所说,.submit()不会在IE中触发.所有其他浏览器工作正常,但在IE(目前为止,8,9,10)它只是不会触发提交.
这是视图代码:
<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 /> …Run Code Online (Sandbox Code Playgroud) 回覆:
上述问题涉及在进行文件选择后,使"更改"事件在浏览器中一致地触发.http://jsfiddle.net/7wR2L/上的示例证明了这一点已得到解决
我的情况有点不同.看来这个问题在另一个背景下变得丑陋.
基于设计约束,我必须使用非文件输入元素('a'标签)来触发文件输入元素上的"click"事件.到目前为止,我的测试看起来,当以这种方式选择文件时,文件输入无法触发"更改"通知.
请查看http://jsfiddle.net/rudylattae/7wR2L/8/上的示例
测试环境:
Windows Server 2008 R2
Windows XP专业版(2002 - SP3)
正如你们中的一些人可能已经知道的那样,Internet Explorer的onchange事件在版本9之前基本上被破坏了.而不是在发生更改时触发,它会在输入字段失去焦点并发生更改时触发.
这导致复选框和单选按钮("使用" onclick代替")和文本字段(" keyup替代使用")的各种变通方法.
但是,对于文件输入我遇到了这个问题,我无法弄清楚我做了什么来通知已经选择了一个新文件,而不是当用户点击其他地方时.我无法将自己附加到鼠标事件中,因为它与鼠标无关; 我无法将自己附加到键盘事件上,因为它与键盘无关.
如果可以解决问题,我愿意使用特定于IE的东西.
其他信息:
我使用jQuery 1.6和live附加事件的方法.
$(".upload").live("change", function() { /* stuff here */ });
Run Code Online (Sandbox Code Playgroud) 我有多个复选框和文件上传输入.如果选中一个或多个复选框并且输入值不为空,我想重新启用按钮.
这是bootply的链接
在这里我的HTML
<div class="upload-block">
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
<input type="file" id="InputFile">
<button id="upload-btn" type="button blue-button"
class="btn blue-button" disabled>Submit</button>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的javascript起点:通过Karl更新change所有输入上的事件然后使用一些条件:
$('.upload-block input').change(function() {
$('#upload-btn').prop(
'disabled',
!($('.upload-block :checked').length && $('#InputFile').val()));
});
Run Code Online (Sandbox Code Playgroud)
这适用于所有复选框,并且#InputFile具有除none之外的值.即选择文件的位置.但是这在IE9中不起作用
如何在IE9中更新此功能?