Sha256: dcf7f118a5da14d35f94cfb6afa518bd9fceb695fe4167b22130f4516565322a
Contents?: true
Size: 875 Bytes
Versions: 4
Compression:
Stored size: 875 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" data-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" data-autocomplete="/url/to/autocomplete" id_element="#id_field"> */ $(document).ready(function(){ $('input[data-autocomplete]').live('focus', function(i){ $(this).autocomplete({ 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); } return false; } }); }); });
Version data entries
4 entries across 4 versions & 1 rubygems