jquery append() doesn't preserve data or click handlers
<p>I am trying to append some links with data and a click handler to a containing div.  </p>

<p>jQuery 1.4.3</p>

<p>Fails in FireFox 5.0/Chrome 13.0.782, but works in IE9</p>

<p>I first create the element as a jQuery object, then add the data and click handler.  Then I use .append() to append it to the container:</p>

<pre><code>var $selector = $('&lt;a href="#" class="x"&gt;Test&lt;/a&gt;');
$selector.data('testdata', "Test");
$selector.click(function(event) {
   alert('Clicked: ' + $(this).data('testdata'));
   return false;
});

$('#container').append($selector);
</code></pre>

<p>I see the link added, but when I click on it, the click handler does not fire.</p>

<p>I thought that maybe I needed to do the append first and then add data+click, but that doesn't work either:</p>

<pre><code>var $selector = $('&lt;a href="#" class="x"&gt;Test&lt;/a&gt;');
$('#container').append($selector);

$selector.data('testdata', "Test");
$selector.click(function(event) {
   alert('Clicked: ' + $(this).data('testdata'));
   return false;
});
</code></pre>

<p>Does append not preserve data and handlers?  It seems that when I .append($selector),  $selector and the newly added DOM object are not one in the same.</p>
