Skip to content

Commit

Permalink
Refactor personal form JavaScript: move inline script to separate file (
Browse files Browse the repository at this point in the history
  • Loading branch information
bbodine1 committed Jan 10, 2025
1 parent b4e057b commit 4a84714
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
18 changes: 18 additions & 0 deletions app/assets/javascripts/inline_replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,21 @@ function init_dependent_form() {
}
}
}

$('.remove-personal-form').off('click');
$('.remove-personal-form').on('click', function (e) {
$(".append_consumer_info").empty();
if ($(".my-household-page")) {
$("#person-<%= @person.id %>").addClass('hidden');
$("a[id^=edit-member]").removeClass('disabled');
$("a[id^=edit-member]").removeAttr('disabled');
// primary_family
var family_table = $("<%= escape_javascript(render 'insured/families/manage_family_table', members: @person.primary_family.active_family_members) %>");
$('#manage_family_content').html(family_table);
}
});

$(document).off('click', '.confirm-member');
$(document).on('click', '.confirm-member', function(e) {
$('#save_personal').trigger('click');
});
19 changes: 0 additions & 19 deletions app/views/people/landing_pages/_personal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,6 @@
</span>
</div>
<% end %>
<script>
$('.remove-personal-form').off('click');
$('.remove-personal-form').on('click', function (e) {
$(".append_consumer_info").empty();
if ($(".my-household-page")) {
$("#person-<%= @person.id %>").addClass('hidden');
$("a[id^=edit-member]").removeClass('disabled');
$("a[id^=edit-member]").removeAttr('disabled');
// primary_family
var family_table = $("<%= escape_javascript(render 'insured/families/manage_family_table', members: @person.primary_family.active_family_members) %>");
$('#manage_family_content').html(family_table);
}
});

$(document).off('click', '.confirm-member');
$(document).on('click', '.confirm-member', function(e) {
$("#save_personal").click();
});
</script>

<% else %>
<%= form_for @person do |f|%>
Expand Down

0 comments on commit 4a84714

Please sign in to comment.