Bug Tracker

Modify

Ticket #9588 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

appendTo behaves differently from append

Reported by: martijn.vanderlee@… Owned by: martijn.vanderlee@…
Priority: undecided Milestone: 1.next
Component: manipulation Version: 1.6.1
Keywords: Cc:
Blocking: Blocked by:

Description

I had a situation where HTML was rendered by jQuery. To explain, we have 2 files.

A is loaded normally and contains all javascript functions that render the HTML and load B through AJAX. B contains static HTML including an element with id "imagesList" and a script which calles the rendering functions in A.

A then appends the HTML of B to the page and the function calls in B call functions in A which try to append HTML to the newly included HTML element in B;

$(html).appendTo('#imagesList');

This worked fine in JQuery 1.3.2 but since then we've upgraded to 1.6.1 in which it no longer rendered anything (according to Chrome inspector).

With 1.6.1 the following DID work however:

$('#imagesList').append(html);

According to the JQuery documentation, there should be no difference between the two statements, but there is.

It almost seems like the appendTo('#imagesList') selector is evaluated at load-time (in this case, before the element is in DOM) and $('#imagesList') is evaluated at run-time. But this is just uneducated speculation.

Confirmed in Chrome 12, FireFox 3, Safari and MSIE 8 and 9.

Change History

comment:1 Changed 2 years ago by rwaldron

  • Owner set to martijn.vanderlee@…
  • Status changed from new to pending
  • Component changed from unfiled to manipulation

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, I've created this boilerplate:  http://jsfiddle.net/rwaldron/da3nM/ Open the link and click to "Fork" in the top menu.

comment:2 Changed 2 years ago by trac-o-bot

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

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

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.