Sha256: 9dbfb0fefd174e59c082c7e6401e32ea8fe3a34c850b69e7f31010c75294fd7b

Contents?: true

Size: 808 Bytes

Versions: 5

Compression:

Stored size: 808 Bytes

Contents

/*
* Unobtrusive autocomplete
*
* To use it, you just have to include the HTML attribute autocomplete
* with the autocomplete URL as the value
*
*   Example:
*       <input type="text" autocomplete="/url/to/autocomplete">
* 
* Optionally, you can use a jQuery selector to specify a field that can
* be updated with the element id whenever you find a matching value
*
*   Example:
*       <input type="text" autocomplete="/url/to/autocomplete" id_element="#id_field">
*/

$(document).ready(function(){
  $('input[autocomplete]').each(function(i){
    $(this).autocomplete({
      source: $(this).attr('autocomplete'),
      select: function(event, ui) {
        if($(this).attr('id_element')) {
          $($(this).attr('id_element')).val(ui.item.id);
        }
        return false;
      }
    });
  });
});

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
rails3-jquery-autocomplete-moc-0.3.0 lib/generators/templates/autocomplete-rails.js
rails3-jquery-autocomplete-moc-0.1.0 lib/generators/templates/autocomplete-rails.js
rails3-jquery-autocomplete-0.2.3 lib/generators/templates/autocomplete-rails.js
rails3-jquery-autocomplete-0.2.2 lib/generators/templates/autocomplete-rails.js
rails3-jquery-autocomplete-0.2.1 lib/generators/templates/autocomplete-rails.js