# Adding custom callbacks to auto\_complete\_field?

**URL:** <https://www.ruby-forum.com/t/adding-custom-callbacks-to-auto-complete-field/118999>\
**Category:** Rails\
**Created:** [November 2, 2007, 1:33am UTC](https://www.ruby-forum.com/t/adding-custom-callbacks-to-auto-complete-field/118999 "2007-11-02T01:33:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![medic0747](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/958977/32.png) [@medic0747](https://www.ruby-forum.com/u/medic0747)\
**Post date:** [November 2, 2007, 1:33am UTC](https://www.ruby-forum.com/t/adding-custom-callbacks-to-auto-complete-field/118999/1 "2007-11-02T01:33:36Z")

</div>

Hi guys,

I was wondering if I can add a custom callback to ‘auto\_complete\_field’  
helper.

I know there are several options (:on\_show, :on\_hide, :after\_update, and  
so on) already, but I want to add another callback, which will be  
triggered every time an action bound to ‘auto\_complete\_field’ is  
completed.

The reason why I want this callback is that I want to show the number of  
hits. I’m using ‘:on\_show’ option for this purpose by counting

-   
elements in query results at the moment. However, it doesn’t work when  
there is no hit or you just refine your query string without leaving  
the text field.

Any help would be appreciated.

Cheers,

Semin
