PDA

View Full Version : BasicDialog hiding with form button



StealthRT
4 Feb 2007, 12:45 PM
Hey all im new at this basicdialog box stuff so here goes...

I would like to be able to add a form button to my already made form to close the dialog box without the use of the "dialog.addButton('Close', dialog.hide, dialog);" or the "X" in the right-top corner. Would it be possible to do this with a onclick"" inside the form button?

Thanks! :)
David

tryanDLS
4 Feb 2007, 12:55 PM
You can call dialog.hide from anywhere, assuming that you can have a ref to the dialog.

StealthRT
4 Feb 2007, 12:58 PM
Thanks for the fast reply tryanDLS:

I've tryed the dialog.hide but it doesnt seem to work.... lets see if im doing it correctly.


<input name="LoginBtn22" type="button" value="Log In" id="LoginBtn22" onclick="dialog.hide" />

That doesnt seem to do anything...

David

Bobafart
4 Feb 2007, 2:22 PM
dude, you don't need any of this onClick business with Jack's code..

use the addButton to add a Close button:



dlg.addButton('Close', dlg.hide, dlg);


OR

make your dialog closable



closable: true,

StealthRT
4 Feb 2007, 2:48 PM
Re-read my first post Bobafart


I would like to be able to add a form button to my already made form to close the dialog box without the use of the "dialog.addButton('Close', dialog.hide, dialog);" or the "X" in the right-top corner. Would it be possible to do this with a onclick"" inside the form button?


David

jack.slocum
4 Feb 2007, 2:58 PM
onclick="Ext.DialogManager.get('your-dialog-id').hide();"

However, using legacy onclick handlers is not a great solution. You should wire up the button from within the code that creates the dialog:

// create the dialog
dialog = new ......

// wire the button
getEl('btn-id').on('click', dialog.hide, dialog);

StealthRT
4 Feb 2007, 10:20 PM
onclick="Ext.DialogManager.get('Login-dlg').hide();" doesnt seem to work either... i must be doing something wrong :(

Heres my javascript:


var HelloWorld = function(){
var dialog, showBtn;
var toggleTheme = function(){
getEl(document.body, true).toggleClass('ytheme-gray');
};

return {
init : function(){
showBtn = getEl('show-dialog-btn');
showBtn.on('click', this.showDialog, this, true);
getEl('theme-btn').on('click', toggleTheme);
},

showDialog : function(){
if(!dialog){
dialog = new YAHOO.ext.BasicDialog("Login-dlg", {
modal:true,
autoTabs:false,
width:390,
height:170,
shadow:true,
proxyDrag:false,
shim: true,
autoScroll: false,
resizable: false,
draggable: false
});
dialog.addKeyListener(27, dialog.hide, dialog);
}
dialog.show(showBtn.dom);
}
};
}();
YAHOO.ext.EventManager.onDocumentReady(HelloWorld.init, HelloWorld, true);


David

manugoel2003
5 Feb 2007, 12:33 AM
change the code to

YAHOO.ext.DialogManager.get('Login-dlg').hide();
Actually Jack gave you the 0.40 version of the code, and I guess u r using 0.33.... I hope it works

StealthRT
5 Feb 2007, 10:58 PM
Thanks manugoel2003, that did it :)

There is a prob. though that i came across. I have a dropdown box within the dialogbox. When i click on it the list appears in the upper right hand corner OUTSIDE of the dialogbox. Is there a fix for this by any chance?

David

manugoel2003
5 Feb 2007, 11:11 PM
could you post your HTML