PDA

View Full Version : BasicDialog content disappear



justCharlie
28 Jun 2007, 2:24 PM
Hello,

I am having problem with the basicdialog, I add the key listener for ESC key to hide the dialog, but after that, i click on same llink to popup the dialog, my content is gone. Here's my code



<link rel="stylesheet" type="text/css" href="includes/Ext/resources/css/ext-all.css" />
<script type="text/javascript" src="includes/Ext/adapter/yui/yui-utilities.js"></script>
<script type="text/javascript" src="includes/Ext/adapter/yui/ext-yui-adapter.js"></script>
<script type="text/javascript" src="includes/Ext/ext-all.js"></script>
<script type"text/javascript" src="includes/js/login.form.js"></script>
<br />
<a href="javascript:void(0);" onclick="show_login_form()">login</a><br />
<!-- <a href="javascript:void(0);" onclick="logout()">logout</a>-->
<div id="login-dlg" style="visibility:hidden;position:absolute;top:0px;">
<div class="x-dlg-hd">Log In</div>
<div class="x-dlg-bd">
<form id='login-form' method='post' action='includes/Ajax/login.auth.php'>
username: <input type='text' name='_username'>
password: <input type='password' name='_username'>
</form>
<!-- <div id='login-form'> </div>-->
</div>
</div>


file: login.form.js



var show_login_form = function() {

var dialog = new Ext.BasicDialog('login-dlg', {
autoCreate: true,
modal:true,
width:500,
height:300,
shadow:true,
minWidth:300,
minHeight:300
});
dialog.on('show', function(dlg)
{
dialog.addKeyListener(Ext.EventObject.ESC, dialog.hide, dialog);
});//end of dialog.on

dialog.show('login-dlg');
}



thanks in advance for any suggestions.

tryanDLS
28 Jun 2007, 3:30 PM
You're recreating the dialog on every click, resulting in duplicate dom entries. This has been covered before - look at the hello dialog example to understand lazy initialization.