Sha256: ba5a895a7f9df38cf43dfce346316b73d06702eb00e374c22a50a11b6e1f32a8

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 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 %>">
  <%= 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.0.12 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.0.11 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.0.11.rc5 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.0.11.rc4 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb