Sha256: 5e6c4c0760db7f327ccacff24d44593ad4cd8e0fd04e1ed99a9a9b3002ecbd6d
Contents?: true
Size: 855 Bytes
Versions: 3
Compression:
Stored size: 855 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({ 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
3 entries across 3 versions & 1 rubygems