1

I'm working with jquery autocomplete

I try to get the control(sender) who called the source value

I use a function to get my list.

something like that (look like):

$("#input").autocomplete({
    source: function (request, response) {
        $.post("/AjaxPostURL", request, response);
    }
}); 
sample From : http://stackoverflow.com/questions/1512607/how-do-i-set-jquery-

autocomplete-to-post-instead-of-get

But mine is an outside function

I want to catch the control inside my function

little like this (look like) :

 $("#input").autocomplete({
        source: myfunction (this)
        }
    }); 

myfunction = function (request, response, control ) {
            $.post("/AjaxPostURL", request, response);
            control.xxx
}

I need to keep request and response. But I also need the control who called the function.

How can I do that?

tank you


Part 2

I think it should look like

source: function( event, ui ) {     
        myfunction(event,ui ,$(this));
        }

The problem: $this does not exist at this time. it will be set only when the function is called. and its undefined on my function(when shes called).

forX
  • 2,063
  • 2
  • 26
  • 47

1 Answers1

0

use this.element to get the caller elememt, e.g.

source: function (request, response) {
    $.getJSON(myFunction(this.element, request.term),
       response);

see also: jQuery autocomplete: select Id from 'source' event

Community
  • 1
  • 1
Aviko
  • 1,139
  • 12
  • 21