I'm having trouble using jQuery with child page
parent.html loads child.html like so: ie user clicks
<a href="#" id="n-email">
JQuery
$('a#n-email').click(function() {
$.ajax({
type: "GET",
url: "/scripts/contact.js",
dataType: "script"
});
$('#content').load("child.htm");
});
contact.js
$(function() {
alert ("contact js hit");
}
This occasionally works. But i can't work out the logic why it works. I've also tried adding adding a ref to the Jquery on the handler also. I feel like i'm missing a trick here.
Thanks to jake + lucus. I've got the following working. Needs a refactor, but works
$('#n-email').click(function() { var e = this; reset(e);
var mypage = $('#contentemail').load("email.php");
$.ajax({
type: "GET",
url: "/scripts/contact.js",
dataType: "script",
success: function(mypage)
{
$(document).append(mypage);
}
});
$('#contentemail').show();
});