diff --git a/app/views/access_levels/_form.html.erb b/app/views/access_levels/_form.html.erb index 33e1f29e..18c53f66 100644 --- a/app/views/access_levels/_form.html.erb +++ b/app/views/access_levels/_form.html.erb @@ -7,13 +7,15 @@ <%= form_check_box f, :member_only %>
<%= f.check_box :has_comment %>
<%= f.check_box :hidden %>
- <%= f.button button_name, class: 'btn btn-sm btn-primary' %> + <%= f.button button_name, class: 'btn btn-sm btn-primary' %> <%= javascript_tag do %> - var id = "#<%=dom_id(f.object) %>"; + var id = "#<% if button_name == 'Save' %>edit_<% end %><%= dom_id(f.object) %>"; var inputs = $(id).parent().find('input'); + $(id).parent().find('button').on('click', function(e) { e.preventDefault(); $(id).append(inputs.clone()); + $(id).append(''); $(id).submit(); }); <% end %> diff --git a/app/views/access_levels/update.js.erb b/app/views/access_levels/update.js.erb index 89d09658..89eded1f 100644 --- a/app/views/access_levels/update.js.erb +++ b/app/views/access_levels/update.js.erb @@ -3,4 +3,7 @@ <% else %> $('#access-level-errors').html('') $('#edit_<%= dom_id(@access_level) %>').parent().replaceWith("<%=j render @access_level, advanced: false %>"); + + var id = "#new_access_level"; + var inputs = $(id).parent().find('input'); <% end %> diff --git a/app/views/partners/_form.html.erb b/app/views/partners/_form.html.erb index b2f2aec0..c947d738 100644 --- a/app/views/partners/_form.html.erb +++ b/app/views/partners/_form.html.erb @@ -4,15 +4,17 @@ <%= f.email_field :email, class: 'form-control' %> <%= f.collection_select :access_level, object.event.access_levels, :id, :name_with_price, {}, { class: "form-control" } %> - <%= f.button button_name, class: 'btn btn-sm btn-primary' %> + <%= f.button button_name, class: 'btn btn-sm btn-primary' %> <%= javascript_tag do %> - var id = "#<%= dom_id(f.object) %>"; + var id = "#<% if button_name == 'Save' %>edit_<% end %><%= dom_id(f.object) %>"; var inputs = $(id).parent().find('input'); var select = $(id).parent().find('select'); + $(id).parent().find('button').on('click', function(e) { e.preventDefault(); $(id).append(inputs.clone()); $(id).append(""); + $(id).append(''); $(id).submit(); }); <% end %> diff --git a/app/views/partners/update.js.erb b/app/views/partners/update.js.erb index 6f3014be..2a4e02c6 100644 --- a/app/views/partners/update.js.erb +++ b/app/views/partners/update.js.erb @@ -3,4 +3,7 @@ <% else %> $('#partner-errors').html('') $('#edit_<%= dom_id(@partner) %>').parent().replaceWith("<%= j render @partner %>"); + + var id = "#new_partner"; + var inputs = $(id).parent().find('input'); <% end %>