Sha256: a6dfd06f0f3945d6e34479c9ad7ae4056aceb57fdcbbfcf0ba3d88f70f64aea2

Contents?: true

Size: 911 Bytes

Versions: 18

Compression:

Stored size: 911 Bytes

Contents

<%
record = form.object
associated_class_name = column.associated_class.name.underscore
class_name = record.class.name.gsub(/.*::/, '').underscore.downcase
text_field_id = "#{class_name}_#{column.association_foreign_key}"
token_url =
  "/#{controller.controller_path}/autocomplete_#{associated_class_name }"
token_input_options = {'crossDomain' => false, 'tokenLimit' => 1}
if current_value = record.send(column.name)
  default_name_method = AdminAssistant::AssociationTarget.new(
    current_value.class
  ).default_name_method
  token_input_options['prePopulate'] = [{
    'id' => current_value.id, 'name' => current_value.send(default_name_method)
  }]
end
%>
<%= form.text_field(column.association_foreign_key) %>
<script type="text/javascript">
$(document).ready(function() {
  $("#<%= text_field_id %>").tokenInput(
    "<%= raw(token_url) %>", <%= raw(token_input_options.to_json) %>
  );
});
</script>

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
admin_assistant-2.4.0 lib/views/_token_input.html.erb
admin_assistant-2.3.2 lib/views/_token_input.html.erb
admin_assistant-2.3.1 lib/views/_token_input.html.erb
admin_assistant-2.3.0 lib/views/_token_input.html.erb
admin_assistant-2.2.8 lib/views/_token_input.html.erb
admin_assistant-2.2.7 lib/views/_token_input.html.erb
admin_assistant-2.2.6 lib/views/_token_input.html.erb
admin_assistant-2.2.5 lib/views/_token_input.html.erb
admin_assistant-2.2.4 lib/views/_token_input.html.erb
admin_assistant-2.2.3 lib/views/_token_input.html.erb
admin_assistant-2.2.2 lib/views/_token_input.html.erb
admin_assistant-2.2.1 lib/views/_token_input.html.erb
admin_assistant-2.2.0 lib/views/_token_input.html.erb
admin_assistant-2.1.1 lib/views/_token_input.html.erb
admin_assistant-2.1.0 lib/views/_token_input.html.erb
admin_assistant-2.0.1 lib/views/_token_input.html.erb
admin_assistant-2.0.0 lib/views/_token_input.html.erb
admin_assistant-2.0.0.pre2 lib/views/_token_input.html.erb