title: Process onclick function after ajax call <f:ajax>
body: <p>I'm trying to select and focus to choosed component ID after submit a form (ajax call). </p>
  
  <pre><code>&lt;script&gt;
  var myFunc = function() {
    document.getElementById('form:#{bean.componentId}').focus();
    document.getElementById('form:#{bean.componentId}').select();
  };
  
  $(document).ready(function() {
    myFunc();
  });
  &lt;/script&gt;
  
  &lt;h:form id="form"&gt;
    &lt;h:commandButton action="#{bean.save}" onclick="return myFunc();" ...&gt;
      &lt;f:ajax execute="@form" render="@form"/&gt;
    &lt;/h:commandButton&gt;
    ...
  &lt;/h:form&gt;
  </code></pre>
  
  <p>This solution is working, but problem is, that <code>&lt;f:ajax&gt;</code> is called AFTER <code>onclick</code>, so the the form is rendered after component selection, and focus is cleared. </p>
  
  <p>How can I call my function AFTER the form is rendered? </p>
  
  <p><strong>update:</strong> (I've tried for example)</p>
  
  <ul>
  <li>add <code>onevent="myFunc();"</code> to <code>f:ajax</code> => leads to refreshing page</li>
  <li>add <code>onevent="myFunc()"</code> to <code>f:ajax</code> => same behaviour as <code>onclick</code> attribute</li>
  <li>next <code>f:ajax</code> with <code>onevent</code> attr. => still the same</li>
  </ul>
  
  <p><strong>update2</strong> (how it should works):</p>
  
  <ul>
  <li>submit button is ajax called</li>
  <li>form is cleaned as needed</li>
  <li>appropriate field is focused (depended on some user choosed factors) </li>
  </ul>