moraes
19 Dec 2006, 3:03 PM
This is a simple tip I would like to share. I'm new to YUI-ext, so it took me some time to figure out; maybe it can help others.
I have some dynamic dialogs (autoCreate:true) and needed a placeholder to display success/error messages in the footer. After the dialog was created, I just added the placeholder with a CSS class that had display:none.
var msg = dialog.footer.createChild({tag: 'div', cls:'msg-inactive'});
Then, at any time, I change its class to the one indicating the type of message that will be displayed:
msg.radioClass('msg-active loading-indicator');
msg.update('Saving...');
Voilá! The message appears. Then in the end of the action I remove it again:
msg.radioClass('msg-inactive');
These are the CSS classes:
/* Messages */
.msg-inactive {
display:none;
font:normal 8pt tahoma, arial;
color:black;
}
.msg-active {
display:block;
height:16px;
}
.loading-indicator {
font-size:8pt;
background-image: url('../images/grid/loading.gif');
background-repeat: no-repeat;
background-position: top left;
padding-left:20px;
margin:5px 5px 0 0;
height:16px;
}
The example above is nice for ajax "loading" actions. I think I'll try to add an "effect" to success/error messages so they highlight and after some time fade and disappear, but I don't know how to do that yet. :lol:
I have some dynamic dialogs (autoCreate:true) and needed a placeholder to display success/error messages in the footer. After the dialog was created, I just added the placeholder with a CSS class that had display:none.
var msg = dialog.footer.createChild({tag: 'div', cls:'msg-inactive'});
Then, at any time, I change its class to the one indicating the type of message that will be displayed:
msg.radioClass('msg-active loading-indicator');
msg.update('Saving...');
Voilá! The message appears. Then in the end of the action I remove it again:
msg.radioClass('msg-inactive');
These are the CSS classes:
/* Messages */
.msg-inactive {
display:none;
font:normal 8pt tahoma, arial;
color:black;
}
.msg-active {
display:block;
height:16px;
}
.loading-indicator {
font-size:8pt;
background-image: url('../images/grid/loading.gif');
background-repeat: no-repeat;
background-position: top left;
padding-left:20px;
margin:5px 5px 0 0;
height:16px;
}
The example above is nice for ajax "loading" actions. I think I'll try to add an "effect" to success/error messages so they highlight and after some time fade and disappear, but I don't know how to do that yet. :lol: