Here's a fuller and simplified example.
function closeFancybox() {
$('#fancy_close').trigger('click');
}
function fixDialog(link) {
var dialog = $('#fancy_ajax');
// Some other stuff is here which corrects some styles and things
inside the content.
// Commenting doesn't affect the problem, though.
/* Handle form submissions. */
dialog.find('form').submit(function() {
// TODO Actually submit form.
closeFancybox();
return false;
});
}
// ...
$(document.createElement('a')).text(word).attr('title', 'Edit
word').appendTo(li)
.attr('href', 'url here')
.each(function() {
var a = this;
$(a).fancybox({
hideOnContentClick: false,
callbackOnShow: function() {
fixDialog(a.href);
}
});
});
When I click the link created in the Javascript, the fancybox appears
as it should. When I click the submit button inside the fancybox, the
fancybox does not close as it should.