Seems like this should be a really simple oversight on my part, but I can only find articles dealing with one aspect of this problem, not the combination.
1) I have an index.php page acts as the anchor for the site and additional 'pages' (essentially different content loaded into a container ) are loaded using the javascript below:
$(document).ready(function() {
$('#content').load('resources/wxCurrent.php');
// Navigation content load
$('#navigation a').click(function() {
var page = $(this).attr('href');
$('#content').load('resources/' + page + '.php');
return false;
});
});
This is working fine.
2) I am looking to execute additional javascript (ultimately Jquery / ajax queries to php pages) on elements defined within the pages called via 1). For testing I have setup a simple form on a php page:
<form name="adminCmdForm" id="adminCmd" method="post" action="resources/admin.php">
<input type="text" name="authcode" placeholder="Auth Code" />
<input type="text" name="command" placeholder="Command" />
<input type="submit" value="runAdminCmd" />
</form>
and can access this form when calling using the javascript in 1). I have then created a simple event handler for the submit event of the form:
$('#adminCmd').submit(function() {
alert('1');
});
If I access the php page on which the form resides directly, I can get this event handler to fire and trigger the alert (if I include the tags in the php page).
Issue:- When I use the javascript loader in 1) to call the page and then try to submit the form, the php loads directly and the event handler appears to be not triggered.
I have tried different forms of playing with this - however I acknowledge that my javascript skills are very poor. I am assuming that my event handler needs to change to cater for the fact that the event is firing from within a different object, but cannot even be sure if this is possible.
For Clarity: index.php -> wxInfo.php (contains form) loaded into container div -> form submit -> admin.php
Thanks in advance for any help or direction on relevant documentation / tutorials on this.