Autocomplete Mootools自动建议定制

Autocomplete Mootools自动建议定制,autocomplete,mootools,Autocomplete,Mootools,我的一个网站扩展插件,用于autosuggest Country、State和City 例如: 州应该有两个输入,如搜索文本和国家代码 从上述插件的文档中,使用 'postVar' : 'text', 'postData':{'country':$('country'.get('value'))}, 用于传递多个参数 此处$'country'设置第一个建议中的国家代码。现在的问题是我无法将country作为输入发送,因为它的集合来自动态javascript调用。如何解决这个问题 审判如下 v

我的一个网站扩展插件,用于autosuggest Country、State和City

例如: 州应该有两个输入,如搜索文本和国家代码

从上述插件的文档中,使用

'postVar' : 'text',
'postData':{'country':$('country'.get('value'))},
用于传递多个参数

此处$'country'设置第一个建议中的国家代码。现在的问题是我无法将country作为输入发送,因为它的集合来自动态javascript调用。如何解决这个问题

审判如下

 var countryAutocomplete = new Autocompleter.Request.JSON('countrySearch', 'www.example.com/country', {
          'postVar' : 'text',
          'minLength': 1,
          'injectChoice': function(areas){

            var choice = new Element('li', {'class': 'autocompleter-choices1', 'id':areas.label});
                new Element('div', {'html': this.markQueryValue(areas.label),'class': 'autocompleter-choice1'}).inject(choice);
                this.addChoiceEvents(choice).inject(this.choices);
                choice.store('autocompleteChoice', areas);

            }


        });


        //set the selected value in a hidden field
        countryAutocomplete.addEvent('onSelection', function(element, selected, value, input) {
            $('country').value = country =  selected.retrieve('autocompleteChoice').id;

            });

        // suggets states
        var stateAutocomplete = new Autocompleter.Request.JSON('stateTxt', 'www.example.com/state', {
          'postVar' : 'text',
          'postData':{'postData':{'country':$('country'.get('value'))},},
          'minLength': 3,
          'injectChoice': function(areas){

            var choice = new Element('li', {'class': 'autocompleter-choices1', 'id':areas.label});
                new Element('div', {'html': this.markQueryValue(areas.label),'class': 'autocompleter-choice1'}).inject(choice);
                this.addChoiceEvents(choice).inject(this.choices);
                choice.store('autocompleteChoice', areas);

            }


        });
任何帮助都将不胜感激

谢谢

看起来

'postData':{'country':$('country'.get('value'))},
应该是:

'postData':{'country':$('country').get('value')},
此外,suggets状态应在每次$'country'更改时更新否?如果是这样,您不应该在选择countryAutocomplete时执行StateSAutoComplete请求吗

看起来这样会更好:

$('country')set("value",selected.retrieve('autocompleteChoice').id);
干杯

$('country')set("value",selected.retrieve('autocompleteChoice').id);