Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#7773 closed bug (fixed)

val() documentation contains misleading example

Reported by: [email protected] Owned by:
Priority: low Milestone: 1.5.1
Component: web Version: 1.4.4
Keywords: Cc: kswedberg
Blocked by: Blocking:


The 2nd example on the documentation page for the setter-version of val() ("Set a single select and a multiple select") contains 4 inputs (2 checkboxes, 2 radio buttons), and some example code that reads

$("input").val(["check1","check2", "radio1" ]);

The effect of that code is to select two of the checkboxes and one of the radio buttons. Of course, if there were a simple text input field on the same page, its content would be set to "check1,check2,radio1", which is stupid. So bad example code for that reason alone.

However, since the only "input" fields on the page are checkboxes or radio buttons, and the example code successfully checks them, it seems reasonable to infer that


would check the first checkbox. It does not. It sets the value of ALL checkboxes to "check1" (which makes sense, syntactically). But the inference would appear reasonable to a newbie.

To further confuse things,


with a single-element list for parameters, does successfully check the first box (and unchecks the 2nd, if it had been checked). Now that just seems weirdly sloppy, since the documentation gives no indication that using a list of parameters somehow behaves differently from a single string parameter.

I just figured this could be cleaned up a bit.

Change History (6)

comment:1 Changed 12 years ago by Rick Waldron

Component: unfiledattributes
Keywords: needsdoc added
Priority: undecidedlow
Status: newopen

comment:2 Changed 12 years ago by Rick Waldron

Cc: kswedberg added

@kswedberg i'm pulling you into this just so its on record

comment:3 Changed 12 years ago by danheberden

Resolution: fixed
Status: openclosed

Changed the documentation to more accurately describe the use of an array as .val()'s argument.

comment:4 Changed 12 years ago by jitter

Keywords: needsdoc removed

comment:5 Changed 12 years ago by [email protected]

You are all awesome. Thanks!

comment:6 Changed 12 years ago by john

Component: attributesweb
Note: See TracTickets for help on using tickets.