Permalink
Browse files

Always include at least one essence track and one essence track ident…

…ifier in instances forms
  • Loading branch information...
1 parent ff83073 commit 7a5059cd424776270a49cc2f03bfa4d31cfde815 @aviflombaum aviflombaum committed Apr 12, 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 7a5059c

Please sign in to comment.