title: JSF Ajax don't work on first load
body: <p>Well, something strange is happening.</p>
  
  <p>When the page loaded the first time, the ajax operation don't work. if I refresh the page, It works fine.</p>
  
  <p>One example is when I click on a select menu option. It should close the dialog and trigger the ajax event, but It just select the option and not close. I need click twice to select, but anyway the ajax is not triggered.</p>
  
  <p>This is my Full Page:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://xmlns.jcp.org/jsf/html"
        xmlns:f="http://xmlns.jcp.org/jsf/core"
        xmlns:ui="http://xmlns.jcp.org/jsf/facelets" &gt;
      &lt;ui:composition &gt;
          &lt;h:head&gt;
              &lt;title&gt;Manager&lt;/title&gt;
              &lt;meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no" /&gt;
              &lt;link rel="stylesheet" href="/Manager/resources/jquery.mobile-1.4.0-rc.1.min.css" /&gt;
              &lt;script src="/Manager/resources/jquery-1.10.2.min.js" /&gt;
              &lt;script src="/Manager/resources/jquery.mobile-1.4.0-rc.1.min.js" /&gt;
  
              &lt;script type="text/javascript" &gt;
                  function renderFormCss () {
                      $('#f_meta_cadastro_empresa').enhanceWithin();
                  }
              &lt;/script&gt;
  
              &lt;f:metadata&gt;
                  &lt;f:viewParam name="cd_meta" value="#{meta_EmpresaWEB.cd_meta}"&gt;&lt;/f:viewParam&gt;
              &lt;/f:metadata&gt;
          &lt;/h:head&gt;
  
          &lt;h:body &gt;
  
              &lt;div data-role="page" &gt;
  
                  &lt;div data-role="header" data-theme="b" class="ui-nodisc-icon" &gt;
                      &lt;a href="#" class="ui-btn ui-noboxshadow ui-icon-arrow-l ui-btn-icon-notext" data-iconshadow="false" &gt;Menu&lt;/a&gt;
                      &lt;h1&gt;Meta&lt;/h1&gt;
                      &lt;a href="#" class="ui-btn ui-noboxshadow ui-icon-arrow-r ui-btn-icon-notext" data-iconshadow="false" &gt;Próximo&lt;/a&gt;
                  &lt;/div&gt;
  
                  &lt;div role="main" class="ui-content ui-nodisc-icon ui-alt-icon" &gt;
  
                      &lt;h:messages id="mensagem_verificacao" showDetail="false" style="color: red;" /&gt;
  
                      &lt;h:form id="f_meta_cadastro_empresa" &gt;
                          &lt;f:passThroughAttribute name="data-ajax" value="false" /&gt;
  
                          &lt;h:selectManyMenu id="select_empresa" value="#{meta_EmpresaWEB.listaMeta_Empresas_Selecionadas}" converter="Meta_EmpresaConverter" &gt;
                              &lt;f:passThroughAttribute name="data-native-menu" value="false" /&gt;
                              &lt;f:passThroughAttribute name="data-shadow" value="false" /&gt;
                              &lt;f:passThroughAttribute name="data-corners" value="false" /&gt;
  
                              &lt;f:selectItem itemLabel="Empresas" itemValue="#{null}" &gt;
                                  &lt;f:passThroughAttribute name="data-placeholder" value="true" /&gt;
                              &lt;/f:selectItem&gt;
  
                              &lt;f:selectItems value="#{meta_EmpresaWEB.listaMeta_Empresa}" var="meta_empresa" itemLabel="#{meta_empresa.nm_empresa}" itemValue="#{meta_empresa}" /&gt;
                              &lt;f:ajax execute="select_empresa" render="lista_empresas" onevent="renderFormCss" /&gt;
                          &lt;/h:selectManyMenu&gt;
  
                          &lt;h:panelGroup id="lista_empresas" layout="block" &gt;
                              &lt;ul data-role="listview" style="margin-top: 30px;" class="ui-nodisc-icon" &gt;
                                  &lt;ui:repeat value="#{meta_EmpresaWEB.listaMeta_Empresas_Selecionadas}" var="meta_empresa" &gt;
                                      &lt;li  data-role="list-divider" style="font-weight: bold;"&gt;
                                          &lt;h2&gt;#{meta_empresa.nm_empresa}&lt;/h2&gt;
                                          &lt;div data-role="controlgroup" data-type='horizontal' data-mini="true" class="ui-btn-right" style="margin: 0 auto;" &gt;
                                              &lt;h:selectManyMenu id="a" value="#{meta_empresa.dias_mes}" &gt;
                                                  &lt;f:passThroughAttribute name="data-native-menu" value="false" /&gt;
                                                  &lt;f:passThroughAttribute name="data-shadow" value="false" /&gt;
                                                  &lt;f:passThroughAttribute name="data-corners" value="false" /&gt;
  
                                                  &lt;f:selectItem itemLabel="Dias" itemValue="#{null}" &gt;
                                                      &lt;f:passThroughAttribute name="data-placeholder" value="true" /&gt;
                                                  &lt;/f:selectItem&gt;
  
                                                  &lt;f:selectItems value="#{meta_EmpresaWEB.dias_Mes}" var="dia" itemLabel="#{dia}" itemValue="#{dia}" /&gt;
                                              &lt;/h:selectManyMenu&gt;
                                              &lt;a href='#' id='moreOptions' class="ui-btn ui-btn-b" style="margin-left: 5px; margin-right: 5px;" &gt;Prêmio&lt;/a&gt;
                                          &lt;/div&gt;
                                      &lt;/li&gt;
                                      &lt;li &gt;
                                          &lt;h:inputText &gt;
                                              &lt;f:passThroughAttribute name="placeholder" value="Vl. Meta" /&gt;
                                          &lt;/h:inputText&gt;
                                      &lt;/li&gt;
                                  &lt;/ui:repeat&gt;
                              &lt;/ul&gt;
                          &lt;/h:panelGroup&gt;
  
                      &lt;/h:form&gt;
  
                  &lt;/div&gt;
  
              &lt;/div&gt;
  
          &lt;/h:body&gt;
  
      &lt;/ui:composition&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I click and It not work, chrome console trigger this error: 
  ReferenceError: mojarra is not defined.</p>
  
  <p>Another strange thing. When I call the page, the console network doesn't change, It just add a line like that:</p>
  
  <p><img src="https://i.stack.imgur.com/u6zhd.png" alt="enter image description here"></p>
  
  <p>Any idea?</p>
  
  <p>Thanks</p>