3 Replies Latest reply on Jun 18, 2011 9:00 PM by Nick Belaevski

    call rich:jquery from another js function

    ginc Newbie

      Hi,

       

      Recently I had to implement some new javascript functions into my app. The problem that i was facing afterwards; how does the user recognize changes made to the website?! Well, in specific the value of an h:inputText changes, so I thought I just highlight the box to advise the user of the changes made.

       

      So far so good, the following code works fine:

       

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
              "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
          <title></title>
      
          <script type="text/javascript" language="JavaScript" src="js/jquery-1.6.1.js"></script>
          <script type="text/javascript" language="JavaScript" src="js/jquery.color.js"></script>
          <script type="text/javascript">
              function test()
              {
                  $('#main_form\\:user_input').animate({ backgroundColor: "#ffff33"}, 500).
                          animate({ backgroundColor: "#ffffff"}, 500).
                          animate({ backgroundColor: "#ffff33"}, 500).
                          animate({ backgroundColor: "#ffffff"}, 500);
              }
          </script>
      </head>
      <body>
      
      <div id="clickme" onclick="test()">
          Click here
      </div>
      
      <input id="main_form:user_input" size="50" value="test" />
      </body>
      </html>
      

       

      As soon as I click on the 'clickme' div, the function 'test' executes the effect.

       

      Now I tried to implement it into richfaces 4, but i failed.

       

      Here is what I did:

       

      <rich:jQuery timing="onJScall" name="highlightUserInput" selector="#user_input"
                       query="animate({ backgroundColor: '#ffff33'}, 500).animate({ backgroundColor: '#ffffff'}, 500).animate({ backgroundColor: '#ffff33'}, 500).animate({ backgroundColor: '#ffffff'}, 500);"/>
      

       

      then i tried to call it:

       

       

      function test()
      {
       var input_box = document.getElementById('main_form:user_input');
      highlightUserInput(input_box);
      }
      

       

      and here is the inputbox which should show the effect:

       

      <h:inputText id="user_input"
                                           size="56"
                                           value="#{ChatBean.inputFieldValue}"
                                           autocomplete="off" />
      

       

      when i try to execute this, I'll get the following error:

       

      Cannot convert onJScall of type class java.lang.String to class org.richfaces.component.JQueryTiming

       

      After some googling i found a chat history saying that the value 'onJScall' does not exist anymore..

       

      Does somebody have a solution for this or can direct me to a page where the rich:jquery behavior is well described?

       

      Thanks

       

      Gregor