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
- <form id="my-form"> .. </form>
- <script>
- $('#my-form').ready(function() {
- //..
- });
- </script>
but it doesn't seem to be triggered when loaded via AJAX.