[英]How to reload the struts2-jquery autocompleter X with value selected from another struts2-jquery autocompleter Y
I have the two strut2 Jquery autocompleter box called x,y in my jsp page. 我的jsp页面中有两个名为x,y的strut2 Jquery自动完成器框。 If i change x , then automatically y also should change according to selected value of x.In struts dojo tags i used listen topics to reload .
如果我更改了x,则y也应根据x的选定值自动更改。在struts dojo标签中,我使用了监听主题来重新加载。 But strut2 jquery not able to reload .
但是strut2 jquery无法重新加载。
my code 我的密码
<sj:autocompleter
id="mapNameList"
name="map_name"
list="%{mapNameList}"
selectBox="true"
selectBoxIcon="true"
onChangeTopics="autocompleteChange"
onFocusTopics="autocompleteFocus"
onSelectTopics="autocompleteSelect"
/>
<label for="map_type">MapType: </label>
<sj:autocompleter
id="mapTypeList"
name="map_type"
list="%{mapTypeList}"
selectBox="true"
selectBoxIcon="true"
onChangeTopics="autocompleteChange"
onFocusTopics="autocompleteFocus"
onSelectTopics="autocompleteSelect"
/>
If you prefer json autocompleter to list one you can do : 如果您希望使用json自动完成程序列出其中一项,则可以执行以下操作:
define the onSelectTopics of the first on to a specific value like 将第一个on的onSelectTopics定义为特定值,例如
onSelectTopics="/mapNameListChange"
define for the second 为第二个定义
listenTopics="/mapNameListChange"
create a function like : 创建一个像这样的函数:
$.subscribe("/mapNameListChange",function(event, data){
//clear the children autocompleters
jQuery('#mapTypeList').val("");
jQuery('#mapTypeList_widget').val("");
var ui = event.originalEvent.ui;
if (ui.item && ui.item.value.length > 0) {
setJQueryAutocompleterURL(jQuery('#mapTypeList_widget'),"your json request", "extraparameter=" + ui.item.value, "the list used in the json", "mapTypeList", "map_type", "/mapNameListChange", "/mapTypeListChange");
};
},null);
where setJQueryAutocompleterURL is another function 其中setJQueryAutocompleterURL是另一个函数
function setJQueryAutocompleterURL(widget,href, hrefparameter, list, id, name, selectTopics, listenTopics) {
var options_auto_iban_widget = {};
options_auto_iban_widget.hiddenid = "mapTypeList";
options_auto_iban_widget.selectBox = true;
options_auto_iban_widget.selectBoxIcon= true;
options_auto_iban_widget.forceValidOption = true;
options_auto_iban_widget.onselecttopics = "/autoDebtorIbanChange";
options_auto_iban_widget.list = list;
options_auto_iban_widget.listkey = "id";
options_auto_iban_widget.listvalue = "name";
options_auto_iban_widget.jqueryaction = "autocompleter";
options_auto_iban_widget.id = id;
options_auto_iban_widget.name = name + "_widget";
options_auto_iban_widget.href = href+"?"+hrefparameter;
options_auto_iban_widget.listentopics = "/autoDebtorBicChange";
jQuery.struts2_jquery_ui.bind(widget,options_auto_iban_widget);
}
Then you will have the extraparameter to get as a param of your json call to filter the result. 然后,您将拥有extraparameter作为json调用的参数来过滤结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.