Sha256: f88d5f11a9202f3e9be29fb26d863b9d78e68f975df98df6dd5226718eca22df
Contents?: true
Size: 877 Bytes
Versions: 16
Compression:
Stored size: 877 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[data-autocomplete]').each(function(i){ $(this).autocomplete({ minLength: 3, 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
16 entries across 16 versions & 1 rubygems