I'm trying to use jQuery's appendTo function to add data to some html that I load from another file.
Why won't this work:
$('#pop-up').load('html_elements/news.html #newsItem', function() {
$(newsItems[$(event.target).attr('href')].title).appendTo($(this).find('.title'));
gameUi.showPopUp();
gameUi.setUpPopUp();
} );
and by "this" I mean this:
$(newsItems[$(event.target).attr('href')].title).appendTo($(this).find('.title'));
all of the individual parts work... newsItems[...] returns a string that is the title. and $(this).find('.title')) returns the element I'm trying to target, but when I test it nothing is appended to the h2 tag.
I'm by no means a javascript / jquery pro so any ideas are welcome. Thanks!