I know that jquery ui dialog box is centered by default. But I have problem when I put into dialog box tabs. First one is a short login form and the second one is a longer reg form.
When I open the dialog box it is centered, but when i switch on the other tab the dialog box isn't centered vertically.
My question: Is it possible to reposition the dialog box with switching tabs?
Here's my code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<style type="text/css">
form>div{
margin-bottom: 15px;
}
form>div>label{width: 30%; display: inline-block;}
</style>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.min.js"></script>
<link rel="stylesheet" href="styles.css">
<script>
$(function() {
dialog = $( "#dialog" ).dialog({
autoOpen: false,
modal: true,
draggable: false,
width: 480,
});
$( "#open-popUp" ).on( "click", function() {
dialog.dialog( "open" );
});
});
$( function() {
$( "#dialog" ).tabs();
});
</script>
</head>
<body>
<h1>Test</h1>
<button id="open-popUp">open</button>
<div id="dialog" title="Basic dialog">
<ul>
<li><a href="#tabs-login">Login</a></li>
<li><a href="#tab-reg">Registration</a></li>
</ul>
<div id="tabs-login">
<form>
<div>
<label for="inputEmail">Email:</label>
<input type="email" id="inputEmail" placeholder="Email...">
</div>
<div>
<label for="inputPassword" class="col-sm-3 control-label">Password:</label>
<input type="password" id="inputPassword" placeholder="Heslo...">
</div>
<button type="submit" class="btn btn-default" id="btn-login">Login</button>
</form>
</div>
<div id="tab-reg">
<form>
<div>
<label for="inputFirstName">First name:</label>
<input type="text" id="inputFirstName" placeholder="Name...">
</div>
<div>
<label for="inputLastName">Last name:</label>
<input type="text" id="inputLastName" placeholder="Name...">
</div>
<div>
<label for="inputE-mail">E-mail:</label>
<input type="text" id="inputEmail" placeholder="E-mail...">
</div>
<div>
<label for="inputPassword">Password:</label>
<input type="password" id="inputPassword" placeholder="Password...">
</div>
<div>
<label for="inputPassword2">Re-password:</label>
<input type="password" id="inputPassword2" placeholder="Re-password...">
</div>
<div>
<label for="inputBirthday">Birthday:</label>
<input type="text" id="inputBirthday" placeholder="Birthday...">
</div>
<div>
<label for="inputCity">City:</label>
<input type="text" id="inputCity" placeholder="City...">
</div>
<button type="submit" class="btn btn-default" id="btn-login">Registration</button>
</form>
</div>
</div>
</body>
</html>