Bug Tracker

Opened 16 years ago

Closed 16 years ago

#1146 closed bug (invalid)

Wrong dom structure in ajax

Reported by: RSA Owned by:
Priority: major Milestone: 1.1.3
Component: ajax Version: 1.1.2
Keywords: Cc:
Blocked by: Blocking:

Description

index.html

<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
function update()
{
	$.post('ajax.html', function(html){
		$('#B').html(html);
		alert($('#A').get().parentNode);
	})
}
</script>
<div id="B" onclick="update()">Click to load</div>

ajax.html

<div id="A">Loading completed</div>

The problem is that you can not use parentNode of an element you loaded through AJAX.

Test case also attached to the ticket.

Attachments (1)

jquery.zip (18.8 KB) - added by RSA 16 years ago.
Test case

Download all attachments as: .zip

Change History (2)

Changed 16 years ago by RSA

Attachment: jquery.zip added

Test case

comment:1 Changed 16 years ago by brandon

Resolution: invalid
Status: newclosed

Get takes a 0 based number of which element to pull from the jQuery object. Try calling get with 0 to get the first matched element $('#A').get(0).parentNode

You could also use Array notation to get the element like this $('#A')[0].parentNode;

Another solution is to use the parent method (recommended as it normalizes browser differences) on the jQuery object like this $('#A').parent();

Note: See TracTickets for help on using tickets.