繁体   English   中英

如何使用从另一个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的strut2 Jquery自动完成器框。 如果我更改了x,则y也应根据x的选定值自动更改。在struts dojo标签中,我使用了监听主题来重新加载。 但是strut2 jquery无法重新加载。

我的密码

             <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自动完成程序列出其中一项,则可以执行以下操作:

将第一个on的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);

其中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);
    }

然后,您将拥有extraparameter作为json调用的参数来过滤结果。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM