title: Primefaces widgetvar functions doesn't work if I submit using ajax call
body: <p>I am trying to enable/disable a button based on the click of another button in my xhtml.
  This doesn't work when I use ajax call but works if I disable ajax.</p>
  
  <p>How do I make this work.</p>
  
  <p>xhtml (this works and button is diabled for few seconds but the page loads and the button is enabled again)</p>
  
  <pre><code>&lt;p:commandButton id="generateBtn" value="Generate Text"
                  action="#{decisionTreeBean.generateText}" styleClass="generateBtn" widgetVar="gb"
                  update=":#{p:component('decisionNotes')}" &gt;
              &lt;/p:commandButton&gt;
  
              &lt;p:commandButton id="clearBtn" value="Clear"
                  action="#{decisionTreeBean.clearText}"  styleClass="clearBtn" widgetVar="cb"
                  update=":#{p:component('decisionNotes')} :#{p:component('searchForm')}" ajax="false"&gt;
              &lt;/p:commandButton&gt;
  </code></pre>
  
  <p>xhtml(doesn't work at all)</p>
  
  <pre><code>&lt;p:commandButton id="generateBtn" value="Generate Text"
                  action="#{decisionTreeBean.generateText}" styleClass="generateBtn" widgetVar="gb"
                  update=":#{p:component('decisionNotes')}" &gt;
              &lt;/p:commandButton&gt;
  
              &lt;p:commandButton id="clearBtn" value="Clear"
                  action="#{decisionTreeBean.clearText}"  styleClass="clearBtn" widgetVar="cb"
                  update=":#{p:component('decisionNotes')} :#{p:component('searchForm')}"&gt;
              &lt;/p:commandButton&gt;
  </code></pre>
  
  <p>Jquery</p>
  
  <pre><code>&lt;SCRIPT type="text/javascript"&gt;
              jQuery(document).ready(function() {
                  if (top.frames.length != 0) {
                      top.location = self.document.location;
                  }
                  jQuery(".clearBtn").click(function(event){
                      PF('gb').disable(); // works without ajax
                  });
              });
  &lt;/SCRIPT&gt;
  </code></pre>