One thing you can do is not use "disabled" at all.

If you decorate the control like it's disabled, and leave it with an ID
(so jquery can find it) but no name, it will be an "unsuccessful control",
and won't send.  If someone enters something in the field, you can use
$('myinput').attr('name', 'myinput') to add the name attribute.

That will get the effect you're looking for, without trying to make events
run on disabled inputs.

- Brian


> Sorry for ~spam, I found that adding the onclick to the parent element (a
> TD
> fortunately) is a good enough solution in this situation.
> BTW: The behaviour is slightly different in IE7 vs Fx2:
>  in IE the click passes through the input, but in Fx the click must be in
> the TD, outside the input.
>
>
> jazzle wrote:
>>
>> I have discovered that if an input is disabled all its events are as
>> well.
>>
>> For example
>> <input type="text" disabled="disabled" onclick="alert('x');" />
>> won't work.
>>
>> I have an input like this and want it disabled (to prevent it being
>> posted) unless the user wants to change the value.
>> I thought I could simple use
>> <input type="text" disabled="disabled"
>> onclick="$(this).removeAttr('disabled');" />
>> or it might need
>> <input type="text" disabled="disabled" id="x"
>> onclick="$('#x').removeAttr('disabled');" />
>>
>> But alas, no luck.
>>
>> Is there some way to force an onclick to work in this situation?



_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to