在Struts 2的jQuery autocompleter与forceValidOption ="假" [英] Struts 2 jquery autocompleter with forceValidOption="false"

查看:200
本文介绍了在Struts 2的jQuery autocompleter与forceValidOption ="假"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在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.

如果有一个bug在这里,我可以直接使用jQuery的自动完成功能,并禁用此功能?!

If there is a bug here, can I use jQuery autocomplete function directly and disable this feature ?!

推荐答案

没有的href 属性的autocompleter用于加载的静态列表。

The autocompleter without href attribute is used to load a static list.

如果它与选择框=用真实,它呈现选择标签来保存它的选项和两个输入领域:一个是价值被​​提交的隐藏字段,而另一种是组合框。这个字段的值应设置为隐藏的字段。
为了使它工作,你应该设置下面的函数

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 autocompleter与forceValidOption =&QUOT;假&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆