Skip to content

Commit

Permalink
Clear old id from id_element if user makes change to autocomplete fie…
Browse files Browse the repository at this point in the history
…ld after having made previous selection.
  • Loading branch information
Dotan committed May 16, 2011
1 parent bdcb802 commit 551715a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/generators/templates/autocomplete-rails.js
Expand Up @@ -96,6 +96,11 @@ $(document).ready(function(){
}
}
}
// If a user changes the field after already making a selection make sure to remove id of a previous selection.
$(this).bind('change.clearId', function(){
$($(this).attr('id_element')).val("");
$(this).unbind('change.clearId');
});
$(this).trigger('railsAutocomplete.select');

return false;
Expand Down

0 comments on commit 551715a

Please sign in to comment.