Sha256: d69346950972fea2fe7ae580f27d4fed3e64cd9e7369b7e83cace4b68dc83ffc

Contents?: true

Size: 782 Bytes

Versions: 8

Compression:

Stored size: 782 Bytes

Contents

export default class Default {
  constructor(element, url) {
    this.url = url;
    if (this.url !== undefined)
      element.autocomplete(this.options(element))
  }

  options(element) {
    return {
      minLength: 2,

      source: (request, response) => {
        console.log("Requesting " + this.url)
        $.getJSON(this.url, {
          q: request.term
        }, response );
      },

      focus: function() {
        // prevent value inserted on focus
        return false;
      },

      complete: function(event) {
        $('.ui-autocomplete-loading').removeClass("ui-autocomplete-loading");
      },

      select: function() {
        if (element.data('autocomplete-read-only') === true) {
          element.attr('readonly', true);
        }
      }
    }
  }
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hyrax-2.0.3 app/assets/javascripts/hyrax/autocomplete/default.es6
hyrax-2.0.2 app/assets/javascripts/hyrax/autocomplete/default.es6
hyrax-2.0.1 app/assets/javascripts/hyrax/autocomplete/default.es6
hyrax-2.0.0 app/assets/javascripts/hyrax/autocomplete/default.es6
hyrax-2.0.0.rc3 app/assets/javascripts/hyrax/autocomplete/default.es6
hyrax-2.0.0.rc2 app/assets/javascripts/hyrax/autocomplete/default.es6
hyrax-2.0.0.rc1 app/assets/javascripts/hyrax/autocomplete/default.es6
hyrax-2.0.0.beta5 app/assets/javascripts/hyrax/autocomplete/default.es6