What I'm looking for is how to access what object I'm binding too. I'm not sure how to explain the question without presenting a code example.
For example, on the autocomplete code below, the extraParams I might wish to set dynamically based on hidden input fields. So the function getSearchParams() would than search all the siblings of the .auto (which would be hidden input fields). Where the .auto is applied to a input text box in a form.
This quick line works, until you have more than one .auto field (ie more than one form).
- $(".auto").siblings("[type=hidden]")
The example code.
- $(".auto").autocomplete("search.php?returnType=json",{
- dataType: "json",
- minChars: 3,
- autoFill: true,
- extraParams: getSearchParams(this), #### !?
- parse: function(data) {
- var array = new Array();
- for(var i=0;i<data.length;i++)
- {
- array[array.length] = { data: data[i], value: data[i]['title'], result: data[i]['title'] };
- }
- return array;
- },
- formatItem: function(row) {
- return row['title'];
- }
- });
- });