2012-01-04 6 views
0

내 웹 사이트 중 하나가 국가, 주 및시 autosuggest 용 http://digitarald.de/project/autocompleter/ 플러그인을 확장 중입니다.Mootools Autosuggestion Customization

예 : 상태는 검색 텍스트 및 국가 코드와 같은 두 개의 입력이 있어야합니다. 위의 플러그인의 문서에서

여러 인수를 전달하는
'postVar' : 'text', 
'postData':{'country':$('country'.get('value'))}, 

를 사용한다.

여기 $('country')은 첫 번째 제안에서 국가 코드를 설정합니다. 이제 문제는 내가 입력으로 country을 보낼 수 없기 때문에 동적 자바 스크립트 호출에서 그것의 세트. 문제를 해결하는 방법.

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 선택시 stateAutocomplete 요청을하지 않아야합니까?

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

건배 : 더 나은 같은 것처럼

그리고

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

이 보인다!

+0

답변 해 주셔서 감사합니다. :) – abhis