我已经使用JSF开发了jQuery自动完成功能并且它工作正常,但是当我添加h:form它时它不起作用.
这是我的代码.
<script>
/* auto complete */
$(function() {
var availableTags = "#{instrumentBean.instrumentList}";
$("#tags").autocomplete({
source: availableTags
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
<div class="ui-widget">
<h:form> <!-- this form was missing -->
<label for="tags">Symbol: </label>
<h:inputText id="tags" />
<h:form id="watchListForm">
<h:commandButton action="#{watchListBean.addtowatchList}"
value="ADD TO WATCH LIST"/>
</h:form>
</div>
Run Code Online (Sandbox Code Playgroud)
使用上面的代码自动完成工作正常,但当我把它放在h:inputbox里面h:form它不工作.没有把它放进去h:form我无法将它的价值提交给JSF支持bean.请给我有价值的想法,让这个正确.
提前致谢
我不确定这是什么原因,但是我使用JSF并且通常表单内部字段的id由表单的id加上前缀为组件的id.所以你应该尝试使用(如果你<h:inputText>在里面<h:form>)
$(function() {
var availableTags = #{instrumentBean.instrumentList};
//the id of the component should be watchListForm:tags, you have to escape
//the semi-colon
$( "#watchListForm\\:tags" ).autocomplete({
source: availableTags
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8563 次 |
| 最近记录: |