Sha256: 1437d50ea62b820d4e76ae58edf9c0e9711fbf8ce8804d52cee8db289f3d41b0

Contents?: true

Size: 1.07 KB

Versions: 9

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.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

9 entries across 9 versions & 1 rubygems

Version Path
typus-3.0.11.rc3 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.1.0.rc6 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.1.0.rc5 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.1.0.rc4 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.1.0.rc3 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.1.0.rc2 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.0.11.rc2 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.0.11.rc1 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb
typus-3.1.0.rc1 app/views/admin/templates/_belongs_to_with_autocomplete.html.erb