using .load for loading pages via AJAX, how to set callback within LOADED page.

using .load for loading pages via AJAX, how to set callback within LOADED page.

Hi,
I'm using $('#container').load method to handle loading all the subpages of my site.
Now the deal is, some sub-pages require extra behavior (like form validation etc.)

I'd love them to be self-contained, so - each sub-page has own JS code that handles all the subpage-specific tasks. This however requires some of them to handle "loaded" callback to access the just-loaded DOM nodes.

Any tips on how to achieve it? I tried putting
  1. <form id="my-form"> .. </form>
  2. <script>
  3. $('#my-form').ready(function() {
  4.   //..
  5. });
  6. </script>
but it doesn't seem to be triggered when loaded via AJAX.