Sha256: 4930e6fbf8a0e05a3d91994f4250f3939b3fa36a9267f76925cde933d7ac05a6

Contents?: true

Size: 1.02 KB

Versions: 2

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.name.to_s.pluralize %>/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 %>">
  <%= 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

2 entries across 2 versions & 1 rubygems

Version Path
typus-3.1.0.rc8 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.1.0.rc7 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb