如何用从另一个struts2 jquery自动补全器Y中选择的值重新加载struts2 jquery自动补全机X
How to reload the struts2-jquery autocompleter X with value selected from another struts2-jquery autocompleter Y
我的jsp页面中有两个名为x,y的strut2Jquery自动补全框。如果我更改x,那么y也应该根据x的选定值自动更改。在struts dojo标记中,我使用侦听主题来重新加载。但是strut2jquery无法重新加载。
我的代码
<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"
/>
如果你更喜欢json自动补全器来列出一个你可以做的:
将第一个的onSelectTopics定义为特定值,如
onSelectTopics="/mapNameListChange"
为第二个定义
listenTopics="/mapNameListChange"
创建一个类似于的函数
$.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);
其中setJQueryAutocompleteURL是另一个函数
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);
}
然后,您将获得一个外部参数作为json调用的参数来过滤结果。
相关文章:
- 使用javascript或jquery检测struts2自动完成标记的值的更改
- 正在获取父<tr>在struts2 jsp页面中使用jquery的表的索引值
- 调用 Struts2 操作,每个 jQuery DataTable 行中的参数
- 如何使用 Struts2+Jquery 验证 Startdate 和 Enddate
- JQuery 在带有 Struts2 的 JSP 中不起作用
- struts2 jquery ajax 和客户端验证不工作
- 如何用从另一个struts2 jquery自动补全器Y中选择的值重新加载struts2 jquery自动补全机X
- 如何使用jQuery将JSON对象数组发布到Struts2操作
- struts2与jquery单选按钮事件问题
- 将Struts2 valuestack变量获取到JQuery
- struts2 jquery表仅显示在第一个选项卡上
- jquery Struts2 jquery-easy-ui
- Struts2和Struts2 JQuery插件兼容性
- 在Struts2中使用JQuery表排序器
- 如何从Jquery函数中设置struts2中的变量
- 如何在jQuery中使用struts2标签作为字符串
- struts2 - JQuery插件:微调器值改变事件
- 如何使用jquery/struts2保持一个选择后提交表单的选择
- 未在struts2 jquery tabbedpannel标记中加载struts2 jquery日期选择器标记
- 使用Ajax、Jquery和Struts2上传文件