3 Replies Latest reply on Mar 6, 2013 4:50 AM by Juraj Húska

    contextMenu targetSelector

    Srikanth Reddy Newbie

      Hi,

      Can any on please give me an example for contextMenu which uses targetSelector attribute, I am hoping that the generated context menu can be used for multiple components.

       

      My Requirment is to associate a context menu to the header of Dynamic Accordion.

        • 1. Re: contextMenu targetSelector
          Juraj Húska Master

          Hey Srikanth,

           

          you need to provide JQuery selector as a value of the targetSelector attribute.

           

          So if you have for example.

           

          <div class="foo">Bar</div>

          <div class="foo">Another content</div>

          <div>Yet another content</div>

           

          then to attach context menu to the first two divs you need to just provide 'div.foo'.

           

          Is that what have you been asking for ? Or you are requesting more complex example, lets say the one which would work with dynamic accordion ?

          • 2. Re: contextMenu targetSelector
            Srikanth Reddy Newbie

            Hi Juraj,

            Can you please show me how can we set the JQuerySelector in this senario with this example.

             

            I have a dynamic Accordion like this.

             

            <rich:accordion id="accCTN" switchType="client"
                      activeItem="#{ctnGrpMgmtController.activeTab}">
            <c:forEach id="ctnRepeatL"
            items="#{ctnGrpMgmtController.ctnGroups}" var="groupName">
              <rich:accordionItem switchType="client" name="#{groupName}"
              headerStyle="height: 10px">
               <f:facet name="header">
                 <h:outputText value="#{groupName}" styleClass="menuable">
                </h:outputText>
               </f:facet>           
              </rich:accordionItem>
            </c:forEach>
            </rich:accordion>

             

            Now I want to associate a context menu on the headers of each of the accortionItems so I used a facet with header and associated a style cla

             

            ss(menuable). And for that style class I am trying to target it to the context menu like this.

             

            <rich:contextMenu id="ctnGrpCtxmenu" targetSelector="menuable"
                   disableDefaultMenu="true">
            <rich:menuItem label="Manage Permissions" 
              id="manPerCtxMnuItm" />
            <rich:menuItem label="Add CTN" 
              id="addCtnCtxMnuItm" />
            </rich:contextMenu>

             

             

            But its not working. I am not aware of how to use the targetSelector attribute to bind with JQuery selector can you please help me resolving this.

            • 3. Re: contextMenu targetSelector
              Juraj Húska Master

              I believe that you need to provide this value of targetSelector: ".menuable" as it uses JQyery selectors.

               

              See for example this for quick overview:

              http://www.w3schools.com/jquery/jquery_ref_selectors.asp

               

              Or complete reference to JQuery selectors:

              http://api.jquery.com/category/selectors/

               

              Does it work ?