Hi Rouslan,
I personally wouldn't call that refactoring, but yeah, the clean-up
looks pretty OK. Just one thing: when you are calling
PMA_ajaxShowMessage() to display an error, you need to pass a second
parameter with a false value. For example:
PMA_ajaxShowMessage(data.error, false);
More info at [1].
I never said that you should not remove the dialog, you're just doing it
wrong. The correct way to do this is by defining a callback that gets
fired when the dialog is closed (this may happen in more than one way)
and remove the dialog there. See example below.
That because the buttons are not where they belong. They should go into
the bottom pane of the dialog. For example:
// Define some buttons that will go into the bottom pane
// of the dialog and bind some callbacks to them
var buttonOptions = {};
buttonOptions[PMA_messages['strGo']] = function () {
// do something useful here
};
buttonOptions[PMA_messages['strClose']] = function () {
$(this).dialog("close");
};
// Create the dialog
$someDiv.dialog({
buttons: buttonOptions,
close: function () {
// This is a callback that gets fired when the user
// or the system try to close the dialog
$(this).remove();
}
});