Bug Tracker

Modify

Ticket #3501 (closed bug: invalid)

Opened 5 years ago

Last modified 4 years ago

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
Blocking: Blocked by:

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

comment:1 Changed 5 years ago by flesler

  • Cc jkozuch, flesler added
  • need changed from Review to Test 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 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

reqsInputs = reqs.find("input")

You are only selecting inputs, you probably wanted the :input selector which includes textarea, select, and button.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.