Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Commit

Permalink
Wire up functionality on form
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Maier committed Jan 3, 2017
1 parent 02689f3 commit fd46451
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
43 changes: 41 additions & 2 deletions _pages/claims/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h1>How it works</h1>
template: '<h3><%=node.value%></h3>'
};
JSONForm.fieldTypes['instructions'] = {
template: '<div class="instructions"><%=node.value%></div>'
template: '<p class="instructions"><%=node.value%></p>'
};
$('#claim').jsonForm({
"schema": json_schema.responseJSON,
Expand All @@ -57,11 +57,50 @@ <h1>How it works</h1>
}
else {
// Set this to a valid endpoint to receive the JSON form contents.
$.post('https://example.gov/', values);
$.post('{{site.baseurl}}/claims/step-2', values);
}
}
});

$('.layout-claims-new form')
.on("change", 'select[name="information.reason"]', function(){
if ($(this).val() == "Manage a recently diagnosed medical condition.") {
$('.dependent').hide();
} else {
$('.dependent').show();
}
})
.on("change", 'input[name="payment.method"]', function(){
var val = $('input[name="payment.method"]:checked').val();
if (val == "direct deposit") {
$('.direct_deposit').show();
} else {
$('.direct_deposit').hide();
}
})
.on("change", 'input[name="claimant.address.street"], input[name="claimant.address.city"], input[name="claimant.address.state"], input[name="claimant.address.zip"]', function(){
dependent_address_street = $('input[name="dependent.address.street"').val();
dependent_address_city = $('input[name="dependent.address.city"').val();
dependent_address_state = $('input[name="dependent.address.state"').val();
dependent_address_zip = $('input[name="dependent.address.zip"').val();
dependent_address = dependent_address_street && dependent_address_city && dependent_address_state && dependent_address_zip;

if (dependent_address == "") {
claimant_address_street = $('input[name="claimant.address.street"').val();
claimant_address_city = $('input[name="claimant.address.city"').val();
claimant_address_state = $('input[name="claimant.address.state"').val();
claimant_address_zip = $('input[name="claimant.address.zip"').val();

$('input[name="dependent.address.street"').val(claimant_address_street);
$('input[name="dependent.address.city"').val(claimant_address_city);
$('input[name="dependent.address.state"').val(claimant_address_state);
$('input[name="dependent.address.zip"').val(claimant_address_zip);
}
});

$('.layout-claims-new form input[value="prepaid debit card"]').click()


}).fail(function() {
console.log('JSON schema could not be retrieved');
});
Expand Down
17 changes: 0 additions & 17 deletions javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,4 @@ $(document).ready(function() {
$(this).parents('.field').removeClass('is-focused')
});

$('.layout-claims-new')
.on("change", 'select[name="information.reason"]', function(){
if ($(this).val() == "Manage a recently diagnosed medical condition.") {
$('.dependent').hide();
} else {
$('.dependent').show();
}
})
.on("change", 'input[name="payment.method"]', function(){
var val = $('input[name="payment.method"]:checked').val();
if (val == "direct deposit") {
$('.direct_deposit').show();
} else {
$('.direct_deposit').hide();
}
});

});

0 comments on commit fd46451

Please sign in to comment.