2012-01-04 5 views
0

私のウェブサイトの1つは、国、州、市の自動応募のためのhttp://digitarald.de/project/autocompleter/プラグインです。Mootools Autosuggestion Customization

例: 州には検索テキストや国コードのような2つの入力が必要です。複数の引数を渡すため

'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); 

      } 


     }); 

任意の助けを感謝します、次のように

をしようとしました。

おかげ

答えて

0

それがあるべき

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

次のようになります。

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

また、$( '国')なしに変更するたびに更新されなければならない "状態をsuggets"?もしそうなら、countryAutocompleteのSelectionでstateAutocompleteリクエストを行うべきではありませんか?

そして

$('country').value = country = selected.retrieve('autocompleteChoice').id; 

方が良い、このようになりますようになっています

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

乾杯!

+0

あなたのお返事ありがとうございます:) – abhis