cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Boksa <mailingli...@boksa.de>
Subject [workaround] validation-message on tabs when using ajax
Date Fri, 23 Jan 2009 14:01:48 GMT
Hi All,

I use the snippet below to enable the "validation-icon on tab" effect  
when using tab-styled groups in my ajax-enabled form template. As  
there were some discussions about this some months ago I thought some  
of you might be interested. Please be aware that this is only a  
(ugly?) workaround to enable the effect and that I am not a dojo 0.4.3- 
guru, however it works for me (tested on Safari 3.2.1/Mac, FF 3.0.1/ 
Mac, IE 7/Win).

The function must be called after the AJAX-response has been processed  
- I call it in my extended cocoon.forms.AjaxForm right after  
"updater.processResponse(data);".

If you have any questions/improvements let me know about them. Hope  
that helps some of you.

Regards

Benjamin



     _addValidationMessageIconToTabs: function() {
         var span; // this will be initialized below only when needed
         var tabAreas = dojo.html.getElementsByClass('forms-tabArea  
forms tabArea');

         dojo.lang.forEach(tabAreas,
             function(tabArea) {
                 var parent = tabArea.parentNode; // no wrapper for  
parentNode in dojo 0.4.3?!
                 var tabs = dojo.html.getElementsByClass('forms-tab  
forms tab', tabArea);

                 dojo.lang.forEach(tabs,
                     function(tab, index) {
                         var tabContent =  
dojo.html.getElementsByClass('forms-tabContent forms tabContent',  
parent)[index];
                         var validationMsgs =  
dojo.html.getElementsByClass('forms-validation-message-popup',  
tabContent);
                         if (validationMsgs.length !== 0) {
                             if (!span) {
                                 span =  
document.createElement('span'); // no wrapper for createElement in  
dojo 0.4.3?!
                                 dojo.html.addClass(span, 'forms- 
validation-message forms validation-message');
                                 var img =  
document.createElement('img');
                                 img.setAttribute('src',  
'servlet:forms:/resource/external/forms/js/templates/images/validation- 
message.gif', 0);
                                 dojo.dom.insertAtPosition(img, span,  
'last');
                             }

                             if (dojo.html.getElementsByClass('forms- 
validation-message forms validation-message', tab).length === 0) {
                                  
dojo.dom.insertAtPosition(span.cloneNode(true), tab, 'last');  // no  
wrapper for cloneNode in dojo 0.4.3?!
                             }
                         }
                     }
                 );
             }
         );
     },


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message