Bug Tracker

Modify

Ticket #11594 (closed bug: wontfix)

Opened 14 months ago

Last modified 8 months ago

Serialize fieldset in Chrome and IE9

Reported by: jragsdale@… Owned by: jragsdale@…
Priority: low Milestone: None
Component: ajax Version: 1.7.2
Keywords: Cc:
Blocking: Blocked by:

Description

.serialize() does not serialize form elements inside a fieldset in Chrome or IE9.

A test case is provided at  http://jsfiddle.net/HQZts/

To reproduce the issue, open the above test case in the following browsers: Firefox, Chrome, and IE 9.

fails: Chrome and IE 9 on Windows 7 64-bit

works: Firefox on Windows 7 64-bit

Change History

comment:1 Changed 14 months ago by dmethvin

  • Owner set to jragsdale@…
  • Status changed from new to pending

It doesn't seem like this is a documented use of the method.

The .serialize() method can act on a jQuery object that has selected individual form elements, such as <input>, <textarea>, and <select>. However, it is typically easier to select the <form> tag itself for serialization ...  http://api.jquery.com/serialize/

So other than a form, there is no current use of .serialize() that requires the code to search inside an element for more elements to process.

Is there some documentation that implied it was correct to use a fieldset like this? At best I'd consider it an enhancement request and not a bug, but I'd prefer to just clarify the docs. It's easy to change the selector to get your desired effect.

comment:2 Changed 14 months ago by jragsdale@…

  • Status changed from pending to new

I want to save bandwidth by sending only a subset of a form in certain cases. Likely, there are workarounds where I can use nested forms to get my desired results.

In the first paragraph of the documentation, there is a sentence that reads, "It operates on a jQuery object representing a set of form elements." A fieldset can contain form elements, thus the confusion.

I am not the first to encounter similar confusion:
http://bugs.jquery.com/ticket/9863
 http://stackoverflow.com/questions/8166991/jquery-serialize-and-serializearray-is-not-working-with-google-chrome

Simplest solution is to make the documentation more clearly express the limitations of .serialize() on elements other than the root form.

comment:3 Changed 14 months ago by ajpiano

  • Keywords needsdocs added

I don't think adding a note about using it on fieldsets is a terrible idea, so +1 for that. This could perhaps be phased in terms of explaining that "a collection that contains an element that contains form elements is not the same as a collection that contains form elements." Using the word "represent" is probably misleading here.

But in terms of workarounds, I just thought it's worth noting that $("#someFieldset :input").serialize() is probably a wiser move than nested forms, etc, so I wanted to chime in with that.

comment:4 Changed 14 months ago by rwaldron

  • Priority changed from undecided to low
  • Resolution set to wontfix
  • Status changed from new to closed
  • Component changed from unfiled to ajax

Closing this as wontfix, docs pending.

comment:5 Changed 8 months ago by mikesherov

  • Keywords needsdocs removed

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.