PDA

View Full Version : run other function before basic dialog show



electric_bit
8 Jan 2007, 11:19 PM
Hii..
i want to ask about basic dialog..

i have this code..


<html>
<head>
<title>Belajar-1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="ajax/yui-ext/style/css/tabs.css" />
<link rel="stylesheet" type="text/css" href="ajax/yui-ext/style/css/basic-dialog.css" />
<link rel="stylesheet" type="text/css" href="ajax/yui-ext/style/css/resizable.css" />
<link rel="stylesheet" type="text/css" href="ajax/yui-ext/style/css/layout.css" />

<script type="text/javascript" src = "ajax/yui/utilities/utilities.js" ></script>
<script type="text/javascript" src = "ajax/yui-ext/yui-ext.js" ></script>

<script type="text/javascript">
var learnBasicDialog = function(){
var dialog, showBtn,eventManager = YAHOO.ext.EventManager;
YAHOO.ext.UpdateManager.defaults.loadScripts = true;
return {
init : function(){
showBtn = getEl('buttonDialog');
showBtn.on('click', this.showDialog, this, true);
testing = this.showAlert;
},
showAlert: function (){
alert("Succes run this func after dialog show!");
},
showDialog : function(){
if(!dialog){ // lazy initialize the dialog and only create it once
dialog = new YAHOO.ext.BasicDialog("layoutDialog", {
modal:true,
autoTabs:true,
width:500,
height:300,
autoScroll: true,
shadow:false,
minWidth:300,
minHeight:250,
proxyDrag: true
});
dialog.addKeyListener(27, dialog.hide, dialog);
dialog.addButton('Close', dialog.hide, dialog);
}
dialog.show(showBtn);
dialog.beforeShow(testing);
}
};
}();
YAHOO.ext.EventManager.onDocumentReady(learnBasicDialog.init, learnBasicDialog, true);
</script>

</head>
<body>
<h3>Belajar Basic Dialog</h3>
<input type="button" id="buttonDialog" value="Show Dialog">
<div align="left">
<div id="layoutDialog" style="visibility: hidden; position: absolute; top: 0px;">
<div class="ydlg-hd">Test Layout Dialog</div>
<div class="ydlg-bd">
<div class="ydlg-tab" title="Form Test Dialog">
heloo
</div>
</div>
</div>
</div>
</body>
</html>



at the top code, i want to execute showAlert function before the dialog is show,
use the dialog.beforeshow(testing), but nothing is execute.

- what's wrong with my code?
- and can i execute other function after the dialog is show, example : dialog.aftershow(testing) ??

thanks..

Animal
9 Jan 2007, 1:06 AM
"beforeshow" is an event!

dialog.beforeShow is an internal function used by BasicDialog.

http://www.yui-ext.com/deploy/yui-ext/docs/output/YAHOO.ext.BasicDialog.html#event-beforeshow



dialog.on("beforeshow", function(){alert("hello")}, dialog, true);

electric_bit
9 Jan 2007, 8:28 PM
thanks animal for reply..

i understand now..