twitter-bootstrap h:commandButton 带有 twitter bootstrap 或其他图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17895869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
h:commandButton with twitter bootstrap or other icon
提问by Sasinda Rukshan
I am using twitter bootstrap css to style. To make icon buttons in it, the standard way is to use "i" tags.
<button type="submit"><i class="icon-search"></i></button>.
But I cant enter it within
<h:commandButton id="myid"><i class="icon-search"></i></h:commandButton>How can I add HTML within the rendered <h:commandButton>?
我正在使用 twitter bootstrap css 来设计样式。要在其中制作图标按钮,标准方法是使用“i”标签。
<button type="submit"><i class="icon-search"></i></button>.
但我无法在<h:commandButton id="myid"><i class="icon-search"></i></h:commandButton>如何在渲染中添加 HTML 中 输入它
<h:commandButton>?
回答by n1k1ch
You can add <i class="icon-search"></i>inside h:commandLink
你可以在<i class="icon-search"></i>里面添加h:commandLink
Command link could be styled as button
命令链接可以设置为按钮样式
<h:commandLink id="btnsearch"
action="search.xhtml"
styleClass="btn btn-default">
<i class="icon-search"></i> Search
</h:commandLink>
回答by Sasinda Rukshan
I just used a hack for now. It's like this (I hid the h:commandButton and added a new submit button).
我现在只是使用了一个黑客。就像这样(我隐藏了 h:commandButton 并添加了一个新的提交按钮)。
<h:form id="myFrm" >
<h:inputText id="search" value="#{user.name}"></h:inputText>
<h:commandButton id="btnsearch" action="search.xhtml" style="display: none"></h:commandButton>
<button type="submit" id="myFrm:btnsearch" name="myFrm:btnsearch"><i class="icon-search"></i></button>
</h:form>

