3 Replies Latest reply on Jun 14, 2013 4:51 AM by Sunil Chowdhary

    Listener beforeshow on textfield

    Panasaki Level 1

      Good afternoun,

       

      I have a question about dialog listeners.

       

      I have this widget definition inside of my dialog:

       

           <vanity

                  jcr:primaryType="cq:Widget"

                  collapsed="{Boolean}true"

                  collapsible="{Boolean}true"

                  title="Vanity URL"

                  xtype="dialogfieldset">

                  <items jcr:primaryType="cq:WidgetCollection">

                      <vanityPath

                          jcr:primaryType="cq:Widget"

                          cls="cq-propsdialog-vanityurl"

                          fieldLabel="Vanity URL"

                          xtype="textfield">

                          <listeners

                                    jcr:primaryType="nt:unstructured"

                                    loadcontent="function(field, record, path){VanityPath.loadPath(field);}"

                         beforeshow="function(field){VanityPath.loadPath(field)}"

                                    beforestatesave="function(field, state){VanityPath.copyResult(field);}"/>

                      </vanityPath>

                      <vanityPathFinal

                          jcr:primaryType="cq:Widget"

                          name="./sling:vanityPath"

                          xtype="textfield"/>

                      <vanityPathRedirect

                          jcr:primaryType="cq:Widget"

                          fieldLabel="Redirect Vanity URL"

                          name="./sling:redirect"

                          type="checkbox"

                          xtype="selection"/>

                  </items>

              </vanity>

       

      The beforeshow is not working and I cannot find what is the right definition.

       

      Thank you for the help.

        • 1. Re: Listener beforeshow on textfield
          rush_pawan Level 4

          Hi,

           

          Two things.

           

          1. there is no "VanityPath" variable defined so not sure how you are referring it. If your intention is to use current object then use "this" to call functions.

          2. your function "function(field){VanityPath.loadPath(field)}" call not ending with ";" (semicolon) to end the statement.

           

          Thanks,

          Pawan

          • 2. Re: Listener beforeshow on textfield
            Panasaki Level 1

            Hi Pawan,

             

            Thank you for your response.

             

            VanityPath is define my javascript code to save if you see the elements I am trying to modify the variable ./sling:vanityPath to change that the user write if the user write /vaniryurl I want to save in the repository /project/vaniryurl.

             

            If I define the listener:

                loadcontent="function(field, record, path){VanityPath.loadPath(field);}". This works.

            But if I define:

                 beforeshow="function(field){VanityPath.loadPath(field);}". Does not work, I have followed your advice, but I received the same the function is not called.

             

            Thank you.

            • 3. Re: Listener beforeshow on textfield
              Sunil Chowdhary

              The reason may be the "VanityPath" is undefined at the time "beforeshow" event gets called.

              It's better if you add console.log  as follows:

                                function(field){

                                console.log(VanityPath);

                                VanityPath.loadPath(field);

                                 }

              and check console output.