Skip to content

Commit

Permalink
Merge pull request #446 from ZeusWPI/fix/446/firefox-form-issues
Browse files Browse the repository at this point in the history
Editing ticket with 0 registrations is broken
  • Loading branch information
TomNaessens committed Mar 27, 2014
2 parents fb01936 + 61cdd8b commit 3ec035f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/views/access_levels/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
<td width="130px"><%= form_check_box f, :member_only %></td>
<td><div class="checkbox"><%= f.check_box :has_comment %></div></td>
<td><div class="checkbox"><%= f.check_box :hidden %></div></td>
<td><input type="hidden" name="_method" value="<%= (button_name == 'Save') ? 'put' : 'post' %>"><%= f.button button_name, class: 'btn btn-sm btn-primary' %></td>
<td><%= f.button button_name, class: 'btn btn-sm btn-primary' %></td>
<%= 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('<input type="hidden" name="_method" value="<%= (button_name == 'Save') ? 'put' : 'post' %>">');
$(id).submit();
});
<% end %>
Expand Down
3 changes: 3 additions & 0 deletions app/views/access_levels/update.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
6 changes: 4 additions & 2 deletions app/views/partners/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
<td><%= f.email_field :email, class: 'form-control' %></td>
<td><%= f.collection_select :access_level, object.event.access_levels, :id, :name_with_price, {}, { class: "form-control" } %></td>
<td></td>
<td><input type="hidden" name="_method" value="<%= action %>"><%= f.button button_name, class: 'btn btn-sm btn-primary' %></td>
<td><%= f.button button_name, class: 'btn btn-sm btn-primary' %></td>
<%= 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("<input type'hidden' name='partner[access_level]' value='" + select.val() + "'>");
$(id).append('<input type="hidden" name="_method" value="<%= (button_name == 'Save') ? 'put' : 'post' %>">');
$(id).submit();
});
<% end %>
Expand Down
3 changes: 3 additions & 0 deletions app/views/partners/update.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>

0 comments on commit 3ec035f

Please sign in to comment.