Something like this will work:
$(function () {
$(".popup").live("mouseover", function () {
var dlg = $.data(this, 'dialog');
if(dlg) dlg.dialog('open');
else $.data(this, 'dialog', $(this).next().dialog());
}).live("mouseout", function () {
$.data(this, 'dialog').dialog('close');
});
});
Why is it that complicated? Well the .dialog()
call wraps the element and moves it to the end of the <body>
element, so .next()
won't find it anymore. So...we need to store a reference to the relevant dialog.
An alternative would be to position the dialog and stick it back in the DOM in a relative way when creating it, either way works.