Permalink
Browse files

add essence track identifier and essence track fields to instantiatio…

…n forms if they don't already exist
  • Loading branch information...
1 parent 084a034 commit 168c50470c82e4ce5399339e4a1b4ab32a4111dd @aviflombaum committed Apr 10, 2012
@@ -80,7 +80,7 @@ def link_to_add_fields(name, f, association)
end
def add_another(f, association, link_text = "Add another...")
- content_tag(:p, :class => "add-another") do
+ content_tag(:p, :class => "add-another #{association}") do
link_to_add_fields(link_text, f, association)
end
end
@@ -1,4 +1,4 @@
-<% f.inputs do %>
+<% f.inputs :class => 'inputs essence_tracks' do %>
<%= link_to_remove_fields "Remove", f %>
<%= f.input :essence_track_type_name, :as => :pbcore_combobox,
:input_html => { :class => "pbcore-autocomplete",
@@ -1,4 +1,4 @@
-<% f.inputs do %>
+<% f.inputs :class => "inputs essence_track_identifier" do %>
<%= f.input :identifier, :as => :string,
:wrapper_html => { :class => "col-1" },
:required => false %>
@@ -1,3 +1,15 @@
+<script>
+$(function(){
+ if ($("fieldset.inputs.essence_tracks").size() == 0){
+ $("p.add-another.essence_tracks a:first").click();
+ }
+
+ if ($("fieldset.inputs.essence_track_identifier").size() == 0){
+ $("p.add-another.essence_track_identifiers a:first").click();
+ }
+})
+</script>
+
<%= assets_navbar %>
<% semantic_form_for [@asset, @instantiation] do |form| %>

0 comments on commit 168c504

Please sign in to comment.