Sha256: 62453b7309a6d9f44a75ac2301ccad9a762727ba3007044ea8e0212a01a3197d
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
:ruby type_collection = field.polymorphic_type_collection type_column = field.association[:foreign_type].to_s selected_type = field.bindings[:object].send(type_column) collection = field.associated_collection(selected_type) selected = field.bindings[:object].send(field.association[:name]) column_type_dom_id = field.dom_id.sub(field.method_name.to_s, type_column) = form.select type_column, type_collection, {:include_blank => true, :selected => selected_type}, :id => column_type_dom_id = form.select field.method_name, collection, {:include_blank => true, :selected => selected.try(:id)}, :style => "margin-left:10px;" = javascript_tag do :plain jQuery(function($) { var urls = #{field.polymorphic_type_urls.to_json.html_safe }; $("##{column_type_dom_id }").bind("change", function(e){ if ("" == $(this).val()) { $("##{ field.dom_id }").html('<option value=""></option>'); } else { $.ajax({ url: urls[$(this).val()], data: { compact: true, all: true }, beforeSend: function(xhr) { xhr.setRequestHeader("Accept", "application/json"); }, success: function(data, status, xhr) { var html = '<option></option>'; $(data).each(function(i, el) { html += '<option value="' + el.id + '">' + el.label + '</option>'; }); $("##{ field.dom_id }").html(html); } }); } }); });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
elucid-rails_admin-0.0.1 | app/views/rails_admin/main/_form_polymorphic_association.html.haml |