Skip to main content

Bug Tracker

Side navigation

#3501 closed bug (invalid)

Opened October 20, 2008 07:39PM UTC

Closed February 07, 2009 02:44PM UTC

Possible Bug with Disabling Inputs?

Reported by: jkozuch Owned by:
Priority: trivial Milestone: 1.3
Component: selector Version: 1.2.6
Keywords: Cc: jkozuch, flesler
Blocked by: Blocking:
Description

Hi,

I think I may have found a bug where it concerns disabling input fields in a form. I have repurposed this code snippet to enable/disable inputs if a checkbox is checked/unchecked:

(document).ready(function() {

var reqsagree = $("#reqsagree");

var inital = reqsagree.is(":checked");

var reqs = $("#supplierform")[inital ? "removeClass" : "addClass"]("gray");

var reqsInputs = reqs.find("input").attr("disabled", !inital);

$("#supplierform").hide();

reqsagree.click(function() {

$("#supplierform").show();

reqs[this.checked ? "removeClass" : "addClass"]("gray");

reqsInputs.attr("disabled", !this.checked);

});

});

What is happening is that even if the checkbox with an id of reqsagree doesn't disable textareas, selects, etc. The only form elements that are disabled are input fields (text, file, submit, etc). I have to disable textarea's, selects, etc using:

var reqsTextarea = reqs.find("textarea").attr("disabled", !inital);

var reqsSelect = reqs.find("select").attr("disabled", !inital);

and enable them on checkbox click using:

reqsTextarea.attr("disabled", !this.checked);

reqsSelect.attr("disabled", !this.checked);

This solution works fine, but I am not sure if this is a bug, or if I have written my code incorrectly (which is a possibility, given that I am still getting used to jQuery.)

Would you be so kind to confirm if this in indeed a bug or just lack of understanding on my part?

Thanks,

Justin

Attachments (0)
Change History (2)

Changed October 21, 2008 01:37AM UTC by flesler comment:1

cc: → jkozuch, flesler
need: ReviewTest Case

Can you turn this loose data into a formal test case ? a minimalistic html file with the requires html and js to reproduce the problem. Thanks.

Changed February 07, 2009 02:44PM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed
reqsInputs = reqs.find("input")

You are only selecting inputs, you probably wanted the

:input
selector which includes textarea, select, and button.