Bug Tracker

Opened 13 years ago

Closed 13 years ago

#5641 closed bug (duplicate)

Calling append on a textarea from a parent window returns old data

Reported by: DWard Owned by:
Priority: minor Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: textarea, append, old, value, val Cc:
Blocked by: Blocking:



I have a textarea on a page. Below are links, which each open a popup with multiple checkboxes. If one or more of these checkboxes are checked and their containing form submitted, jQuery loops through each option and appends (using the elem.append(string) function) the iterated checkbox value to the textarea on the parent page before closing the popup.


The append functions correctly if appending only, however...

If, for example 5 checkbox values were added to the the textarea, then the user decides they didn't want any of the values and it was all a mistake, then they would, naturally remove the values from the textarea. All is OK, until they decide to add, for example two values to the textarea now that they've cleared it. If they add these two new values, they will find that the earlier-selected values reappear in the textarea with the two new values on the end.


Instead of using the elem.append(string) function, use the elem.val(string) function to set the textarea (or any other input if also an issue) value with the concatenated current elem.val() and the value to append. Example below:

$(mySelector).val($(mySelector).val() + valueToAppend);


I'm not totally sure that this would be classed as a bug, but it has been an issue, as it's almost as if the value of the textarea is being cached instead of simply gathering the value of the target element upon appending its value.

Dan Ward

Change History (1)

comment:1 Changed 13 years ago by dmethvin

Resolution: duplicate
Status: newclosed

Duplicate of #5524.

Note: See TracTickets for help on using tickets.