jQuery UI dialog steals focus.

jQuery UI dialog steals focus.

Hey.
Need your help.
I want remove standart close button of jQuery UI dialog, and bind event to another link.
But also I wanna set confirmation (with different plugin) to my close button.

When I did it, and show my confirm dialog, I can't change focus, when I click on the custom close link.

Problem is: try close UI dialog with different link, and after click it, can't set focus to any element.

Code example:

jQuery(document).ready(function() {
$('#file').dialog({
draggable: false,
resizable: false,
modal: true,
width: '80%',
closeOnEscape: false,
dialogClass: 'dialog dialog-with-panel dialog-reset',
create: function(ev, ui) {
var target = $(ev.target),
dialog = target.parents('.dialog');

dialog.find('.ui-dialog-titlebar').remove();
}
});

$('.close').on('click', function(e) {
e.preventDefault();

 Alertify.dialog.confirm('sdfdsfd', function() {
$('#file').dialog('close');
})

console.log($(':focus'))
$('a:last').focus();
console.log($(':focus'))
});

});