Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#8743 closed bug (invalid)

ONE MORE TIME: in FireFox 4 the $("#element_id *") duplicate imput elements

Reported by: scutarug@… Owned by: scutarug@…
Priority: undecided Milestone: 1.next
Component: ajax Version: 1.5.2
Keywords: Cc:
Blocked by: Blocking:

Description

this is the second ticked that I issue but this time I got it in jsFiddle.

here is the jsFiddle link: http://jsfiddle.net/QEaav/19/

Change History (13)

comment:1 Changed 7 years ago by timmywil

I'm confused. What's the bug exactly? I don't see the duplicates. http://jsfiddle.net/timmywil/QEaav/21/ And is this related to a certain browser?

comment:2 Changed 7 years ago by timmywil

Owner: set to scutarug@…
Status: newpending

comment:3 in reply to:  1 Changed 7 years ago by anonymous

Replying to timmywil:

I'm confused. What's the bug exactly? I don't see the duplicates. http://jsfiddle.net/timmywil/QEaav/21/ And is this related to a certain browser?

do you see it in FF4?

comment:4 Changed 7 years ago by timmywil

I feel dumb. You said firefox 4 in the title. I went straight to the fiddle and didn't understand what the bug was from the fiddle. I do see duplicate inputs in the serializeArray response, but you are serializing the inputs as well as their parents and I believe that is the correct response. If you select only the inputs, you will get back the proper response. $('#holder :input').serializeArray()

An example: http://jsfiddle.net/timmywil/PyZGH/1/

comment:5 Changed 7 years ago by cowboy

The correct usage for .serializeArray() is either:

$('form').serializeArray()

or

$(':input').serializeArray()

but never both, as you'll get duplicates.

Last edited 7 years ago by cowboy (previous) (diff)

comment:6 Changed 7 years ago by timmywil

Component: unfiledajax
Resolution: invalid
Status: pendingclosed

comment:7 Changed 7 years ago by anonymous

I know that adding the :input is working, but don't you thing that this a huge inconsistency with other browsers? Doesn't this defies the purpose of jQuery?

I think of "*" as select every element, and absolutely NOT same element twice. After all why would I ever need that functionality, not to mention that this functionality is available in FireFox 4?

However this example its all over my project ... And now should I go and do: if you are ff4 do this else do that? What's jQuery going to do for me?

I just hope it's a issue with ff4 being in beta and not a jQuery problem. Just wanted to let you know about issue.

Thanks for your time.

comment:8 Changed 7 years ago by dmethvin

Seems like a programmer error to me, anonymous. The docs say that if you select a form it serializes all the elements in the form. Your selector selects both the form and its children so what exactly did you expect? Nonetheless, we have documented this now so you won't trip over it again.

comment:9 Changed 7 years ago by anonymous

I don't remember adding a form element in my example. If I did it's may bad. Our project is in .net and we can't have more then one form elements on a page and we use components that has "form" (div) that holds the input elements.

However you do realize that this happens only in FF4. None of other browsers does that.

Another thing is that let's say I don't use the serialize() and I use just the selector and I want to loop through it and what do I do? Check for FF4?

Think about it.

comment:10 Changed 7 years ago by Rick Waldron

Firefox 4 doesn't change the fact that your code is simply incorrect. If you write unexpected code, unexpected things happen.

comment:11 Changed 7 years ago by anonymous

I don't think you read my post :)

I don't use a form element and I want all the elements in a container! In this case I get dupes in FF4!

I hope I made my self clear.

comment:12 Changed 7 years ago by ajpiano

Not using a form element around input/select/textarea/buttons is, as rwaldron stated, "simply incorrect."

comment:13 Changed 7 years ago by cowboy

LOL

Note: See TracTickets for help on using tickets.