document.ready() analog for $(html)/$.ajax
<p>I use jQuery to attach some plugins in the $(document).ready() handler - for example, $(".date").datepicker(). However, when I load content using $("...html..."), for example from $.ajax(.., success(data){}), or from ajaxForm({target:...}), document.ready() is obviously not called. UPDATE: as pointed out it <strong>is</strong> called but still I don't know what portion/element was loaded.</p>

<p>I can't just do ready() again because it will re-attach plugins second time to elements that have it already. So I have to do it manually in every case, like, I do success(data) { item = $(data); initDatePickerEtc(item); }.</p>

<p>Is there a better way?</p>

<p>There's <a href="http://plugins.jquery.com/project/livequery/" rel="nofollow">Live Query</a> plugin that does it for events. Is there something that will allow me to track HTML elements creation and perform actions then? Something like</p>

<pre><code>$.oncreation(".date", function() { $(this).datepicker(); });
// or at least
$.oncreation(function() { $(this).find(".date").datepicker(); });
</code></pre>

<p>Great if it will also process existing elements... like Live Query works for both existing at the time of click() call, and the future-created elements.</p>

<p>Note that I'll be happy tracking only elements created by jQuery. So it's either jQuery provides extension point to its html() function or not, I guess. Now, from the jQuery sources it does not:</p>

<pre><code>html: function( value ) {
 return value === undefined ?
  (this[0] ?
   this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") :
   null) :
  this.empty().append( value );
},
</code></pre>

<p>Maybe if I replace html() so that even 3-rd party plugins (e.g. ajaxForm) will use my version (that will fire $.creation callback) instead of default jQuery one... will it work? There're problems with this approach - it's not only html(), it's append(), etc... and it would be great to get the event only if result of $("") is appended to the document... since when it's in memory I don't need datepicker().</p>
