passing parameters to jQuery's select2 ajax call
- by Cary
I'm attempting to pass an extra parameter to an ajax call within select2:
$(".auto-sug").select2({
width:'element',
minimumInputLength:2,
ajax: {
url: "/action/get-custom.php",
data: function (term, page) {
return {
q: term, // search term
page_limit: 10
};
},
results: function (data, page) {
return {results: data.stuff};
}
}
});
I actually want to pass another parameter to the ajax call... the id of the element itself
<input type="text" class="auto-sug" name="custom" id="3383" />
however, I'm unable to figure out how to actually access the id of the element (3383) or any other value on the page.
select2: http://ivaynberg.github.com/select2/