0

I have below piece of code where the function opens a new pop up with blank. But it should display headers atleast ( like Account Demographics:). Can someone give an idea why this happens. In a different copy of the page with some other changes , it working fine.

Code snippet:

   function getSurveyPopup(acctid) {

        alert('survey pop up'+acctid);
        $("#poptableBody").empty();
        if ($('#sliderbox').width() < 50) {
            $('#toggleBtn').click();
        }

        getSurveyDetailRecord(acctid);
        return false;
   }

   function getSurveyDetailRecord(id) {
       //alert('survey detail'+id);
       var acctId = '';
       var accountName = '';
       var addressLine = '';
       var addressCity = '';
       var retSurveydetailResult = '<br/>'+'<div style="font-size:14px;font-Weight:bold;margin:5px;text-indent:5px;text-align:Left;font-family: Arial;">Account Demographics:</div>';

       <apex:repeat value="{!AcctSurveyResults}" var="wrapAcct">
         acctId = '{!wrapAcct.acct.id}';             

         if(acctId == id)
         {
             accountName = escapeSpecialChars("{!wrapAcct.acct.Name}");
             <apex:repeat value="{!wrapAcct.address}" var="addr">
                    addressLine = escapeSpecialChars("{!addr.Name}");
                    addressCity = '{!addr.City_State_Zip__c}';                        
             </apex:repeat>

             var svyName = '';

             <apex:repeat value="{!wrapAcct.svyTgtRatingMap}" var="st">
                var svyHasVal = '{!wrapAcct.svyTgtRatingMap[st]}';
                var svyType = escapeSpecialChars("{!st}");
                Alert('Hi');
                var svyImg = '<img src = " '+((svyHasVal == 'true') ? '{!URLFOR($Resource.SurveyImages_ABV, 'Images/icon-OK.png')}' : '{!URLFOR($Resource.SurveyImages_ABV, 'Images/failed-icon.png')}') + '" />';
                svyName = svyName + svyImg +'    '  + svyType+'    ';                  
            </apex:repeat>

             retSurveydetailResult += '<div style="font-size:12px;font-Weight:bolder;margin:5px;text-indent:5px;text-align:left; font-family:Verdana;">'
                   + '<table style="font-size:12px;font-Weight:500;max-width: 250; color:Black;margin:5px;text-indent:0px; text-align:left; font-family:Verdana;">'
                   + '<tr><td>' + accountName + '</td></tr>'
                   + '<tr><td>' + addressLine + '</td></tr>'
                   + '<tr><td>' + addressCity + '</td></tr>'
                   + '</table>'
                   + '<br/>';


             retSurveydetailResult +=  svyName +'<hr/>';


             <apex:repeat value="{!wrapAcct.questResponses}" var="SvyDet">
                 var svyTypeQuest = escapeSpecialChars("{!SvyDet}");

                 retSurveydetailResult += '<div id="divTubing" style="font-size:14px;font-Weight:bold;margin:5px;text-indent:5px;text-align:Left;font-family:Verdana;">'+ svyTypeQuest + ':</div>'
                                          +'<table style="font-size:12px;margin: 5px; font-Weight:400;text-align:left;text-indent:5px;font-family:Verdana;">';
                 var count =0;                             
                 <apex:repeat value="{!wrapAcct.questResponses[SvyDet]}" var="qr">
                         var question = escapeSpecialChars("{!qr.Question_Text_vod__c}");
                         var questRes = '{!qr.Response_vod__c}';

                         if(questRes == ''){
                             questRes = escapeSpecialChars("{!SUBSTITUTE(qr.Text_vod__c,'"','\\"')}");
                         }
                         if(questRes == '')

                         {
                            questRes = questRes.replace('\"','\\"');
                            questRes = questRes.replace('\n','<br/>');
                            var fulldate = '{!qr.Date_vod__c}';
                            if( fulldate != '')
                            {
                              questRes = formatDate(fulldate);
                            }
                         }
                         if(questRes == ''){
                             var fulldate = '{!qr.Datetime_vod__c}';
                             if(fulldate != '')
                             {
                                 questRes = formatDate(fulldate);
                             }
                         }
                         if(questRes == ''){
                             questRes = '{!qr.Number_vod__c}';
                         }

                     if(count == 0){
                         retSurveydetailResult +=  '<tr><td><b>'+ question +'</b></td><td><b>' + questRes + '</b></td></tr>';
                     }else{
                         retSurveydetailResult +=  '<tr><td>'+ question +'</td><td>' + questRes + '</td></tr>';
                     }
                     count = count+1;                              
                 </apex:repeat>                    
                 retSurveydetailResult += '</table>'+'<hr/>';
             </apex:repeat>

        }
       </apex:repeat>

       //alert(retSurveydetailResult);

       var oTable = document.getElementById("popupTable");
       var tbody = document.createElement("tBody");

       while (oTable.hasChildNodes()) {
            oTable.removeChild(oTable.firstChild);
       }

       oTable.appendChild(tbody);
       var temp = tbody.ownerDocument.createElement('div');
       temp.innerHTML = retSurveydetailResult;
       tbody.parentNode.replaceChild(temp, tbody);

   }
  • 1
    Check the browser debugger for any javascript errors that are being thrown and thus not making it to the code that injects your html – Eric Jun 3 '15 at 16:43
0

Thanks Eric! Just got the reason. In a line it was Alert('Hi'); A in capital is not recognized by javascript

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.