Sha256: bbcb94d3a0d5bcf6c07b22138897d08cbb40bd52d52c699d9fa0fc2200dc35e0

Contents?: true

Size: 634 Bytes

Versions: 3

Compression:

Stored size: 634 Bytes

Contents

// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

$(document).ready(function() {
  new autoComplete({
      selector: 'input[name="q"]',
      minChars: 1,
      source: function(term, response){
          $.getJSON('/products/autocomplete_endpoint', { term: term }, function(data){
            term = term.toLowerCase();
            var matches = [];
            for (i=0; i<data.length; i++)
              if (~data[i].toLowerCase().indexOf(term)) matches.push(data[i]);
            response(matches);
          });
      }
  });
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
autocompl-0.2.2 test/dummy/app/assets/javascripts/products.js
autocompl-0.2.1 test/dummy/app/assets/javascripts/products.js
autocompl-0.2.0 test/dummy/app/assets/javascripts/products.js