Note that there are some explanatory texts on larger screens.

plurals
  1. POIE7 / IE8 interaction with JQuery .removeAttr('disabled'), not applying css
    primarykey
    data
    text
    <p>This is more of a curiosity than a question, but I'm wondering why the following isn't working.</p> <p>Say I have an html form with a selector and a submit button.</p> <pre><code> &lt;form action="/foo/createActivity" method="post" name="activityform" id="activityform" &gt; &lt;select name="activity" id="activity" &gt; &lt;option value="1" &gt;Activity 1&lt;/option&gt; &lt;option value="2" &gt;Activity 2&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" class="submit" id="add" value="Add &gt;&gt;"/&gt; &lt;/form&gt; </code></pre> <p>Then I have an ajax call with jQuery defined</p> <pre><code>$('#activity').change(function() { tryDisable($('#activity').val()); }); function tryDisable(activity) { $.ajax({ type: 'GET', contentType: 'application/json', cache: false, url: '/foo/checkActivity', data: { activity: activity }, success: function(disableSubmit) { if (disableSubmit == "true") { $('#add').attr('disabled', 'true'); } else { $('#add').removeAttr('disabled'); // Problem in IE, doesn't take away CSS of disabled // $('#add').css({"text-align" : "center"}); // NO idea why the above fixes the problem, TODO find out } }, dataType: 'json' }); return false; } </code></pre> <p>You'll see in my comments that just the .removeAttr('disabled') is causing the button to re-enable, but the button still <em>looks</em> like it's disabled (gray-ed out). However, if I 'tickle' the css via jquery as I did in the commented out line, the correct, non-disabled styling applies. Firefox and Chrome work fine with just the first line, as I expected.</p> <p>Does anyone know why this might be? What's IE doing here that's so odd?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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