Sha256: ba8bc65264dbdd8eb3c2d0a9afc1edfade4eac25c143fe0d69260b41f9dc5850

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

function autocomplete(id) {
  console.log(id)
  $('#' + id + ' input:text').autocomplete({
    source: "search_content",
    minLength: 5,
    select: function (event, ui) {
      section_id = generateID();

      element = '<li id="' + section_id + '" class="cb-relational__item">';
      element += '<a href="/noticias/' + ui.item.content_builder_category.slug + '/' + ui.item.slug + '" class="cb-relational__link" target="blank"></a>';
      element += '<h2 class="cb-relational__caption cb-editable">' + ui.item.title + '</h2>';
      element += '<div class="cb-tools">';
      element += '<a class="cb-tools__btn cb-tools__btn--small cb-relational__btn--move fa fa-arrows" href="#"></a>';
      element += '<a class="cb-tools__btn cb-tools__btn--small cb-tools__btn--delete fa fa-trash" href="#' + section_id + '"></a>';
      element += '</div>';
      element += '</li>';

      $("#" + id + ' ol').append(element);
      activeMediumEditor();
      activeSortable();

      return false;
    },
    create: function () {
      $(this).data('ui-autocomplete')._renderItem = function (ul, item) {
        return $("<li>")
          .append("<a>" + item.title + "</a>")
          .appendTo(ul);
      }
    }
  })
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_admin_content_builder_rails_6-1.2.0 app/assets/javascripts/rails_admin/helpers/autocomplete.js.erb
rails_admin_content_builder_rails_6-1.1.0 app/assets/javascripts/rails_admin/helpers/autocomplete.js.erb
rails_admin_content_builder_rails_6-1.0.1 app/assets/javascripts/rails_admin/helpers/autocomplete.js.erb
rails_admin_content_builder_rails_6-1.0.0 app/assets/javascripts/rails_admin/helpers/autocomplete.js.erb