Bug Tracker

Opened 11 years ago

Closed 11 years ago

#3501 closed bug (invalid)

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

Change History (2)

comment:1 Changed 11 years ago by flesler

Cc: jkozuch flesler added
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.

comment:2 Changed 11 years ago by dmethvin

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.

Note: See TracTickets for help on using tickets.