Struts 2 jquery 自动完成器,带有 forceValidOption=“false" [英] Struts 2 jquery autocompleter with forceValidOption="false"
问题描述
我已将 Struts 2 jquery 自动完成标记 forceValidOption
设置为 false 为:
I have set the Struts 2 jquery auto complete tag forceValidOption
to false as:
<sj:autocompleter list="destinationAccounts" id="sample"
listKey="accountNo" name="toAccount"
listValue="%{accountNo + " " + firstName + " " + lastName }"
forceValidOption="false"/>
forceValidOption
不起作用,它强制用户从选项中进行选择,并在用户离开输入时自动清理用户输入的数据.生成的javascript如下:
The forceValidOption
is not working and it forces the user to select from options and will auto-clean user entered data, when user leaves input.
The generated javascript is as:
var options_sample_widget = {};
options_sample_widget.hiddenid = "sample";
options_sample_widget.selectBox = true;
options_sample_widget.forceValidOption = false;
options_sample_widget.jqueryaction = "autocompleter";
options_sample_widget.id = "sample_widget";
options_sample_widget.name = "toAccount.accountNo_widget";
options_sample_widget.href = "#";
options_sample_widget.formids = "ownToOtherForm";
jQuery.struts2_jquery_ui.bind(jQuery('#sample_widget'),options_sample_widget);
显示设置了forceValidOption
.
我应该设置其他选项以使其工作吗?!
Should I set other options to make it work?!
我已经在陈列柜中对其进行了测试,但仍然无法使其正常工作.
I have test it in the showcase and still I could not make it work.
如果这里有问题,我可以直接使用jQuery自动完成功能并禁用此功能吗?!
If there is a bug here, can I use jQuery autocomplete function directly and disable this feature ?!
推荐答案
不带 href
属性的自动完成器用于加载静态列表.
The autocompleter without href
attribute is used to load a static list.
如果它与 selectBox="true"
一起使用,它会渲染 select
标签来保存它的选项和两个输入字段:一个是提交值的隐藏字段,另一个是组合框.此字段的值应设置为隐藏字段.要使其工作,您应该设置以下功能
If it's used with selectBox="true"
, it renders select
tag to hold its options and two input fields: one is a hidden field which value is submitted, and another is a combobox. The value from this field should be set to a hidden field.
To make it work you should set the following function
$(".s2j-combobox-input.ui-autocomplete-input").keyup(function(e){
$("#sample").val($(".s2j-combobox-input.ui-autocomplete-input").val())
});
这篇关于Struts 2 jquery 自动完成器,带有 forceValidOption=“false"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!