JQuery dialog is a fine plugin, but sometimes it doesn't work as we want to. I had a situation where my modal window pop up always third time and i had no idea why...
Event for my button was binded well and popUpWindow execute every time, but open: function had strange behaviour. The code looked like this:
function popUpWindow(id, title, containerId) {
$('#' + id).dialog('destroy');
$('#' + id).dialog({
autoOpen: false,
bgiframe: true,
modal: true,
title: title,
open: function (event, ui) {
$('#' + id).append("simple Div Tag");
$('#' + id).parent().appendTo($("form"));
},
close: function (event, ui) {
$('#' + id).parent().appendTo($('#' + containerId));
$("body").css("overflow", "auto");
}
});
$('#' + id).dialog('open');
$('#' + id + " input:text:visible:first").focus();
}
Function worked fine everywere else except a one particular userControl.
The solution is to hold the modal div in a variable, so new funcion takes the form:
function popUpWindow(id, title, containerId) {
var divObj = $('#' + id);
divObj.dialog('destroy');
divObj.dialog({
autoOpen: false,
bgiframe: true,
modal: true,
title: title,
open: function (event, ui) {
divObj.append("simple Div Tag");
divObj.parent().appendTo($("form"));
},
close: function (event, ui) {
divObj.parent().appendTo($('#' + containerId));
$("body").css("overflow", "auto");
}
});
divObj.dialog('open');
$('#' + id + " input:text:visible:first").focus();
}
Hope this helps someone and saves precious time.
Thanks
ReplyDeleteHelpful article
Thanks, this helped me out
ReplyDeleteThank you .Your article really saved me a lot of time
ReplyDeleteIndeed! This solved my issue. Thanks!
ReplyDeleteThank you. It helped:)
ReplyDeleteHi
ReplyDeleteWhat will be containerId here?
Hi... how would I reference child objects in the dialog? I need to communicate with elements within the div...
ReplyDeleteBTW: I am totally, totally new to js/jq :(
Perfect Answer. You saved another life :)
ReplyDeleteGreat...........:). You saved mine life too :)
ReplyDeleteSorry I'm starting to learn this, how do you use that function? Can you show the html code as well?
ReplyDeleteThat would help.
Thanks
R
this is correct answers...great...
DeleteYay, worked like a charm !
ReplyDeleteThanks, this helped me.
ReplyDeleteThanks! This really helped!
ReplyDeleteI should found this article before... That would save a lot my time. I spent a whole day to make things work, and finally found this as solution. THANKS!
ReplyDeleteYou the MAN!
ReplyDeleteThank you. You saved me.
ReplyDeleteCould you post an example of how to use the syntax highlighter within Blogger? Thanks!
ReplyDeleteChris check this:
Deletehttp://mlawire.blogspot.com/2009/07/blogger-syntax-highlighting.html
wow really superb you had posted one nice information through this. Definitely it will be useful for many people. So please keep update like this. pop over to this site school signs uk
ReplyDelete