I have a custom search field which searches for a type of content depending on the radio box selected. I have applied autocomplete functionality to the field using hook_form_alter but only want the autocomplete functionality to be available for one of the search types.
Is it possible to conditionally detach the Drupal.behaviors.autocomplete from the text field using my own js?
Update: I have managed to disable the autocomplete functionality by unbinding the events, but I do not know how to add/bind it again:
// update search box text when search type is changed $(SI_SEARCH.radio).change(function() { // get search type SI_SEARCH.search_type = $(this).val().trim(); switch(SI_SEARCH.search_type) { case 'course' : break; case 'university' : // disable autocomplete $('#edit-search').unbind('keydown keyup blur'); break; } })