Submit with ENTER key and catcomplete widget
I have the following code and I'd like to submit the form when hit ENTER key:
- $(document).ready(function(){
-
- $('input[data-autocomplete]').live('focus', function(i){
- $(this).catcomplete({
- delay: 500,
- source: $(this).attr('data-autocomplete'),
- select: function(event, ui) {
- $(this).val(ui.item.value);
- if ($(this).attr('id_element')) {
- $($(this).attr('id_element')).val(ui.item.id);
- $($(this).attr('id_hidden_element')).val(ui.item.id);
- }
- return false;
- }
- });
- });
-
- $.widget("custom.catcomplete", $.ui.autocomplete, {
- _renderMenu: function( ul, items ) {
- var self = this,
- currentCategory = "";
- $.each( items, function( index, item ) {
- if ( item.category != currentCategory ) {
- ul.append( "<li class='category'>" + item.category + "</li>" );
- currentCategory = item.category;
- }
- self._renderItem( ul, item );
- });
- }
- });
- });
Thank You for help.