2
안녕하세요 전 jQueryjQuery를위한 Ajax AutoComplete에서 추가 매개 변수를 전달하는 방법?
내 jquery options = { serviceUrl: "<? echo $this->config->item('base_url'); ?>index.php/welcome/autocomplete" };
a = $('#query').autocomplete(options);
아약스 AutoComplete 사용하고 있습니다.
var a = $('#query').autocomplete({
serviceUrl:'service/autocomplete.ashx',
minChars:2,
delimiter: /(,|;)\s*/, // regex or character
maxHeight:400,
width:300,
zIndex: 9999,
deferRequestBy: 0, //miliseconds
params: { country:'Yes' }, //aditional parameters
noCache: false, //default is false, set to true to disable caching
// callback function:
onSelect: function(value, data){ alert('You selected: ' + value + ', ' + data); },
// local autosugest options:
lookup: ['January', 'February', 'March', 'April', 'May'] //local lookup values
});
그래서 여분의 매개 변수를 전달할 수있는 보았다 n 새로운 매개 변수를 만들려면 원하는 이걸
var a = $('#query2').autocomplete({
serviceUrl: "<? echo $this->config->item('base_url'); ?>index.php/welcome/autocomplete",
id:'query2'
});
어떻게 자동 완성 코드에서 해당 추가 매개 변수에 액세스 할 수 있습니까 ?? 그
처음에<div class="autocomplete-w1"></div>
이 ID를 추가하려면
변경하십시오. 도와주세요 ........ ........................
업데이트
이 함수에 내 id 매개 변수를 추가하려고했습니다.
function Autocomplete(el, options) {
this.el = $(el);
this.el.attr('autocomplete', 'off');
this.suggestions = [];
this.data = [];
this.badQueries = [];
this.selectedIndex = -1;
this.currentValue = this.el.val();
this.intervalId = 0;
this.cachedResponse = [];
this.onChangeInterval = null;
this.ignoreValueChange = false;
this.serviceUrl = options.serviceUrl;
this.isLocal = false;
this.options = {
autoSubmit: false,
minChars: 1,
maxHeight: 300,
deferRequestBy: 0,
width: 0,
highlight: true,
params: {},
fnFormatResult: fnFormatResult,
delimiter: null,
zIndex: 9999,
id:'test'
};
this.initialize();
this.setOptions(options);
}
나는 기본값 test
을 주었다. 내가 $this.options.id
에 경고 할 때 나는 항상 'test'
값을 얻는다. passig jquery2
은 얻지 못한다. 거기에 무슨 문제가 있니?