Note that there are some explanatory texts on larger screens.

plurals
  1. POInput button click is not invoked through JavaScript in IE9
    primarykey
    data
    text
    <p>I'm working with MVC 3, javascript and jQuery.</p> <p>I've got a hidden button which click() function needs to be called from javascript. This works great on every browser except IE9.</p> <pre><code>$('#fakeSubmitBt').click(function () { $('#fileUplSubmitBt').click(); }); </code></pre> <p>Here, fileUplSubmitBt is the hidden button and fakeSubmitBt is the visible button which I need to click instead. I noticed that if a call three times </p> <pre><code>$('#fileUplSubmitBt').click(); </code></pre> <p>then the form is submitted, but in the backend the elements of the form are not recognized.</p> <p>UPDATE: thanks to the hints given by Ricardo and Jay, I tried to use trigger('click') but also this path failed.</p> <p>In the following I post the code that is shaming me (it's MVC3 using Razor):</p> <pre><code> &lt;script type="text/javascript"&gt; function s2cPanelReady() { $('#fakeBrowseBt').click(function () { $('#fileUplRadio').prop("checked", true); $('#gravatarRadio').prop('checked', false); $('#realFileUpload').click(); }); $('#fakeSubmitBt').click(function () { if ($('#gravatarRadio').prop("checked")) { $('#grvatarSubmitBt').click(); } else if ($('#fileUplRadio').prop("checked")) { $('#fileUplSubmitBt').trigger('click'); } }); } &lt;/script&gt; &lt;div class="inputForm"&gt; &lt;div class="inputField"&gt; &lt;div class="userPicLargeFrame"&gt; &lt;img src="/Images/Get?id=@Model.ID&amp;size=40" class="userPicLarge" /&gt; &lt;/div&gt; &lt;/div&gt; @using (Html.BeginForm("ChangePicture", "User")) { &lt;div class="inputField"&gt; &lt;input type="radio" id="gravatarRadio" /&gt; &lt;span class="inputLabel"&gt;Gravatar:&lt;/span&gt; @Html.EditorFor(model =&gt; model.Preferences.GravatarEmail) @Html.ValidationMessageFor(model =&gt; model.Preferences.GravatarEmail) &lt;/div&gt; &lt;input id="grvatarSubmitBt" type="submit" value="Save Pic" style="display:none;" /&gt; } @using (Html.BeginForm("UploadPicture", "User", FormMethod.Post, new { encType = "multipart/form-data", name = "uplPicForm" })) { &lt;div class="inputField"&gt; &lt;input type="radio" id="fileUplRadio" /&gt; &lt;span class="inputLabel"&gt;Save your own pic:&lt;/span&gt; &lt;span class="inputLabel"&gt; &lt;span style="display:inline-block; position:relative;"&gt; &lt;input type="file" id="realFileUpload" name="fileUpload" style="position:relative; opacity:0; -moz-opacity:0 ;" /&gt; &lt;span style="display:inline-block; position:absolute; top:0px; left:0px;"&gt; &lt;input id="fakePathBox" type="text" value="" readonly /&gt; &lt;input id="fakeBrowseBt" type="button" value="..."/&gt; &lt;/span&gt; &lt;/span&gt; &lt;/span&gt; &lt;input id="fileUplSubmitBt" type="submit" name="submit" value="Upload" style="display:none;" /&gt; &lt;/div&gt; } &lt;div class="inputField"&gt; &lt;span class="inputLabel"&gt; &lt;input id="fakeSubmitBt" type="button" value="Submit" class="s2cButton" /&gt; &lt;/span&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>UPDATE N.2: I tried to remove all javascript stuff, and simply put the file upload HTML tag with a simple submit button: nor in this case on IE9 I'm able to submit the form!! </p> <p>Sometimes it runs, sometimes it is not fired at the first click, but only at the second click (and in this case the submitted form hasn't got the selected file, so server-side this results in an error...), sometimes it simply doesn't fire the submit button, no matters how many click I do. </p> <p>This issue starts to make me crazy....</p> <p>Any other hint?</p> <p>Thank you very much!</p> <p>Best</p> <p>cghersi</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload