I have an existing autocomplete field outside of Drupal that uses jQuery UI's autocomplete functionality and makes a call to a custom PHP script to parse the input and return formatted data as JSONP. I need to migrate this field to Drupal.
I've created a custom field module, but I can't figure out how to bind the JS functions if the field allows multiple values. At the moment, I have the IDs of the HTML elements I need to use set with the name-'.$delta.' to append the delta to the ID name. Is there a way to bind JS functionality to a field in Drupal like a custom field behavior call or will I need to create a function in my JS to manipulate the ID and extract the delta that way?
I need one function to run when the field is presented as a widget (node/edit), and a different function to run when the field is presented as a formatter (node/view).
Also, is there a hook to tell Drupal about my JSON service PHP file, or do I just drop it in an includes folder in my module and link to it from my JS file?