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
Copy code
<form id="my-form"> .. </form>
<script>
$('#my-form').ready(function() {
//..
});</script>
but it doesn’t seem to be triggered when loaded via AJAX.
Finally I’ve figured out the problem. It was all about content filtering (second parameter of .load method).
Now, instead of filtering on JS side, I’m doing it server-side.