I am using a Jquery modal window with an asp button inside. The problem here is that jQuery-UI creates the dialog outside of the element, so clicking on it never submits the form. I have tried to fix this by adding:
$(this).parent().appendTo(jQuery("form:first"));
However, I am new to Jquery and not sure where to add this line. I thought I was close any help? Thanks!
jQuery(function ($) {
var OSX = {
container: null,
init: function () {
$("input.osx, a.osx").click(function (e) {
e.preventDefault();
var dlg = $("#osx-modal-content").modal({
overlayId: 'osx-overlay',
containerId: 'osx-container',
closeHTML: null,
minHeight: 80,
opacity: 65,
position: ['0',],
overlayClose: true,
onOpen: OSX.open,
onClose: OSX.close
});
});
},
open: function (d) {
var self = this;
$(this).parent().appendTo(jQuery("form:first")); // <--APPENDING HERE
self.container = d.container[0];
d.overlay.fadeIn('fast', function () {
$("#osx-modal-content", self.container).show();
var title = $("#osx-modal-title", self.container);
title.show();
d.container.fadeIn('slow', function () {
setTimeout(function () {
var h = $(document).height() - 25
d.container.animate(
{height: h},
300,
function () {
$("div.close", self.container).show();
$("#osx-modal-data", self.container).show();
}
);
}, 200);
});
})
},
close: function (d) {
var self = this;
d.container.animate(
{top:"-" + (d.container.height() + 20)},
300,
function () {
self.close();
}
);
}
};
OSX.init();
});
$(el).modal({appendTo: ‘form’}); fixed the problem
see below for exact usage.