1

I tried to use jQuery UI autocomplete. I have different autocomplete field in one page and I need to get data with different sources (different URL) depend to which autocomplete field is used. I know how can I get the typed data (request.term), but I can't find the way to get the selected field ID.

$(".ac").autocomplete({
             
     source: function(request, response) {       
       id = '??? the actually used field #id ???';
        $.ajax({
         type: "POST",
         url: "/admin_/sql/autocomplete/"+id, 
         data: "test=...",
         async: false,
         success: function(data) {  
           
           } 
       });
     },
     search: function() {
      // 
    },
     focus: function() {
      // 
      return false;
     },
     select: function(event, ui) {
      //
      return false;
     }
    });

1 Answer 1

1

almost took my half day ...

$(this).attr('element').attr('id')

Sign up to request clarification or add additional context in comments.

1 Comment

The success function is missing the response(data);, so the return json or list appear in the combobox

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.