私はprimefaceを使用しようとしていますが、期待した結果が得られません。私はenterキーを押したときに私のコードスニペットは、それもprimefaces pを使用した後、最初の列のボタンではなく期待される検索にヒットし、上記のコードでEnterキーを押すと、pを介して期待される検索ボタンにヒットしません:defaultCommand
<h:form id="searchForm" styleClass="searchForm">
<p:panelGrid columns="3">
<p:commandButton id="left-overlay-btn" value="" styleClass="xschnapp-search-filter-menu" />
<p:inputText required="true" placeholder="#{cc.attrs.searchTip}" value="#{cc.attrs.queryProperty}" />
<p:commandButton value=" " id="searchButton" action="#{cc.attrs.searchAction}" styleClass="xschnapp-search-action" />
</p:panelGrid>
<p:defaultCommand target="searchButton">
</h:form>
を下回っている:defaultCommand。
http://blog.primefaces.org/?p=1787
誰かが手動で、また失敗thatsの検索ボタンをクリックしてJavaScriptを使用するように私にadviced。おそらく私の弱いjavascriptの知識のために。以下は、JavaScriptと誰かが私を助けてくださいまた、代わりに目的の検索ボタン
<h:form id="searchForm" styleClass="searchForm" onkeypress="if (event.keyCode == 13) {document.getElementById('searchButton').click(); return false}">
<p:panelGrid columns="3">
<p:commandButton id="left-overlay-btn" value="" styleClass="xschnapp-search-filter-menu" />
<p:inputText required="true" placeholder="#{cc.attrs.searchTip}" value="#{cc.attrs.queryProperty}" />
<p:commandButton value=" " id="searchButton" action="#{cc.attrs.searchAction}" styleClass="xschnapp-search-action" />
</p:panelGrid>
</h:form>
の最初の列のボタンを打つことでコードスニペットです。
元の質問を改善したのはなぜですか? https://stackoverflow.com/questions/36330347/hitting-enter-goes-to-wrong-button – Kukeltje
こんにちはKukeltje、あなたの提案に感謝します。私は次回のことを覚えています。 – apts
他の1つまたはこの1つを削除してください...あなたの選択を取ってください... – Kukeltje