Sha256: aef425c814c4a163b3b3a6eff2bfdeb1c3f8d967603aff95ecccc37fd5493b30

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

<% content_for :javascripts do %>
  <% label = "#{@item.class.model_name.underscore.gsub("/","_")}_#{related_fk}" %>
  <script type="text/javascript">
    $(document).ready(function () {
        $("#tokenInput_for_<%= related_fk %>").tokenInput("/admin/<%= association.class_name.tableize %>/autocomplete", {
            hintText: "",
            queryParam: 'term',
            tokenLimit: 1,
            <% if (item = @item.send(attribute)) %>
            prePopulate: [ { id: <%= item.id %>, name: "<%= item.to_label %>" } ],
            <% end %>
            onAdd: function(item) { $("#<%= label %>").val(item.id); },
            onDelete: function (item) { $("#<%= label %>").val(""); }
        });
    });
  </script>
<% end %>

<li id="<%= attribute_id %>">
  <%= form.label related_fk, "#{label_text} <small>#{message}</small>".html_safe %>
  <%= form.hidden_field related_fk %>
  <input id="tokenInput_for_<%= related_fk %>"
         size="30"
         type="text"
         value="<%= @item.send(attribute).try(:to_label) %>" />
</li>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
typus-3.1.0.rc18 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.1.0.rc17 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.1.0.rc16 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.1.0.rc15 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb