Created
          August 27, 2010 12:25 
        
      - 
      
 - 
        
Save adonaldson/553264 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // From http://stackoverflow.com/questions/3583989/jquery-autocomplete-pass-targeted-element-attribute-as-an-extra-parameter | |
| $("#autocomplete input").each(function() { | |
| var that = this; | |
| $(that).autocomplete({ | |
| source: function(request, response) { | |
| $.ajax({ | |
| url: "search.php", | |
| dataType: "json", | |
| data: { | |
| term: extractLast(request.term), | |
| extra_param: $(that).attr('id') | |
| }, | |
| success: function(data) { | |
| response($.map(data, function(item) { | |
| return { | |
| label: item.label, | |
| value: item.name | |
| } | |
| })) | |
| } | |
| }) | |
| }, | |
| }); | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Yay! That's worked - cheers mate :)