1

I have created Modal using Salesforce Lightning Design System but it is not showing modal when i click the button. When i click the button it is not adding the style class using jquery.

My Problem is it is not adding the style class using java script button when i click on the button.

Following is my code.

<apex:page standardController="Account" extensions="ActivityDetailExtension" standardStylesheets="false" sidebar="false">
   <apex:stylesheet value="{!URLFOR($Resource.SLDS0105, '/assets/styles/salesforce-lightning-design-system-vf.css')}"/>
   <style>
      .table-border {margin-top:20px;}
      .table-border tr td {border: 1px solid #d8dde6;}
      .table-border tr th {border: 1px solid #d8dde6;}
      .sub-goal {margin-left:50px;}
   </style>
   <script src="https://code.jquery.com/jquery-1.10.1.min.js" type="text/javascript"></script>
   <script>
      j$ = jQuery.noConflict();

      j$(document).ready(function(){
         j$('#modal').removeClass('slds-fade-in-open');
         j$('#backdrop').removeClass('slds-backdrop--open');
      });

      //Modal Open
      function openModal(){
         alert('togglebutton');
        j$('#modal').addClass('slds-fade-in-open');    
        j$('#backdrop').addClass('slds-backdrop--open');
        alert('classes are added successfully');

      }         
      //Modal Close
      function closeModal(){
        j$('#modal').removeClass('slds-fade-in-open');
        j$('#backdrop').removeClass('slds-backdrop--open');
      }
   </script>
   <div class="slds">
      <apex:form >
         <apex:commandButton onclick="openModal();" reRender="Modal" styleClass="slds-button slds-button--brand" value="Create New Sub-Goal" />
         <apex:outputPanel id="Modal">
            <div id="Modal" role="dialog" tabindex="-1" aria-labelledby="header43" class="slds-modal">
               <div class="slds-modal__container">
                  <div class="slds-modal__header">
                     <button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close">
                        <svg class="slds-button__icon slds-button__icon--large" aria-hidden="true">
                           <!-- <use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#close"></use>-->
                        </svg>
                        <span class="slds-assistive-text">Close</span>
                     </button>
                     <h2 id="header43" class="slds-text-heading--medium">Modal Header</h2>
                  </div>
                  <div class="slds-modal__content slds-p-around--medium">
                     <p>Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore
                        quis aute consequat ipsum magna exercitation reprehenderit magna. Tempor cupidatat consequat elit dolor adipisicing.
                     </p>
                     <p>Dolor eiusmod sunt ex incididunt cillum quis nostrud velit duis sit officia. Lorem aliqua enim laboris do dolor eiusmod officia. Mollit incididunt nisi consectetur esse laborum eiusmod pariatur proident. Eiusmod et adipisicing culpa deserunt nostrud
                        ad veniam nulla aute est. Labore esse esse cupidatat amet velit id elit consequat minim ullamco mollit enim excepteur ea.
                     </p>
                  </div>
                  <div class="slds-modal__footer">
                     <button class="slds-button slds-button--neutral" onclick="closeModal()">Cancel</button>
                     <button class="slds-button slds-button--brand">Save</button>
                  </div>
               </div>
            </div>
            <div class="slds-backdrop"></div>
         </apex:outputPanel>
         <!-- Code for Popup Ends-->
      </apex:form>
   </div>
</apex:page>
</div>
2
  • One problem is mismatching case: j$('#modal') in the JavaScript and id="Modal" in the HTML.
    – Keith C
    Commented Jan 28, 2017 at 9:17
  • @Ketih C removed the id from that div it will take j$('#modal') from class for that div. Commented Jan 28, 2017 at 9:39

0

You must log in to answer this question.

Browse other questions tagged .