how to pass extra parameter in Ajax AutoComplete for jQuery?
hi i am using Ajax AutoComplete for jQuery
in my jquery i am using
options = { serviceUrl: "<? echo $this->config->item('base_url'); ?>index.php/welcome/autocomplete" };
a = $('#query').autocomplete(options);
i saw that i can pass extra parameters like
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
});
so i want to create n new parameter and pass it like this
var a = $('#query2').autocomplete({
serviceUrl: "<? echo $this->config->item('base_url'); ?>index.php/welcome/autocomplete",
id:'query2'
});
How can i access that extra parameter from the autocomplete code ?? i want to add that id to my
.autocomplete-w1
initially it looks like this
<div class="autocomplete-w1"></div>
i want to change it to
<div id="jquery2" class="autocomplete-w1"></div>
please help................................
UPDATE
i tried to adding my id parameter to this function
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,
deferR开发者_高级运维equestBy: 0,
width: 0,
highlight: true,
params: {},
fnFormatResult: fnFormatResult,
delimiter: null,
zIndex: 9999,
id:'test'
};
this.initialize();
this.setOptions(options);
}
i gave a default value test
. when i alert $this.options.id
i always getting 'test'
the value i passig jquery2
is not getting . what is the problem there ????
hmmm. i have solved it .
i added extra parameter id
a = $('#query').autocomplete({
serviceUrl: "<? echo $this->config->item('base_url'); ?>index.php/welcome/autocomplete",
id: 'query'
});
in my jquery.autocomplete.js
in
function Autocomplete(el, options) {
i get that parameter like
this.id = options.id;
now i can add it to div's id
<div class="autocomplete-w1" id='+this.id+'></div>
thanks.................... :) :) :D
精彩评论