Tuesday, 13 January 2015

Add a Helpbutton in pageblock using javascript.

    Helptext is preety much important for new application user and sometimes we can have requirement to add helptext to pageblock title/header...



  • We have helptext attribute in pageBlockSection but not in pageBlock as of now.
  • So we can append a helpbutton using Jquery .See the script below.


<apex:page standardController="Case">
<head>
    <script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
    <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>  
    <apex:form >
      <apex:pageBlock mode="edit"  tabStyle="Case" >                                    
          <apex:pageBlockSection title="Subject" columns="1" id="subject" collapsible="false" >
              <!-- Configure your help text from Field Help text-->                                                                        
              <apex:pageBlockSectionItem helpText="{!$ObjectType.Case.fields.subject.inlineHelpText}">
                  <apex:outputLabel value="{!$ObjectType.Case.fields.subject.label}"/>                                      
                  <apex:outputPanel >
                      <apex:inputField value="{!case.subject}" />              
                  </apex:outputPanel>                                        
              </apex:pageBlockSectionItem>
           </apex:pageBlockSection>
       </apex:pageBlock>
     
       <script>
                 var elementToAppend = '<span class="helpButton" id="example-title-_help"><img src="/s.gif" class="helpOrb" style="width: 20px!important;height:15px!important;"/></span>';
                 $("[id$='subject']").find('h3').after(elementToAppend);
                 sfdcPage.setHelp('example-title', 'Demo help Text');
        </script>
    </apex:form>
 
</apex:page>


Hope this helps..:-)

1 comment:

Add a Helpbutton in pageblock using javascript.

    Helptext is preety much important for new application user and sometimes we can have requirement to add helptext to pageblock title/hea...