8 Replies Latest reply on Mar 1, 2012 5:51 AM by ram ram

    jQuery do not work after A4j reRender. Expecting a solution !

    son lexuan Newbie

      Hello!

       

      When I use a4j in jsf , has conflict between a4j reRender and jQuery 1.4.2 .

      Below is a small example:

       

      * Code:

      <%@page contentType="text/html" pageEncoding="UTF-8"%>
       
      <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
      <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
      <%@taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
       
       
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">
       
      <f:view>
          <html>
              <head>
                  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                  <title>Test A4J</title>
                  <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
                  <script type="text/javascript">
                      $ = jQuery.noConflict();
                      $(document).ready(function(){
                          $("#input1").click(function(){
                              alert("Hi JBOSS !");
                          });
                      });                
                  </script>
              </head>
              <body>           
                  <h:form prependId="false">
                      <h:outputText value="Label1"></h:outputText>
                      <h:inputText id="input1"></h:inputText>
                      <br/>
                      <h:outputText value="Label2"></h:outputText>
                      <h:inputText id="input2">
                          <a4j:support event="onclick" reRender="input1"
                                       ajaxSingle="true" limitToList="true"
                                       process="input1">
                          </a4j:support>
                      </h:inputText>
                  </h:form>
              </body>
          </html>
      </f:view>

       

      * Library:

      Untitled4.png

       

      * Before reRender: jQuery alert : Hi JBOSS ! when click into input1.

      Untitled5.png

       

      * After reRender: when click into input2( reRender ) --> click input1--> Result: not alert !

      Untitled6.png

       

       

      THANKS FOR ANSWER !