Merge pull request #153 from houdiniproject/data_reload_campaign_fix

If you change a campaign slug, we redirect to the proper page
This commit is contained in:
Eric Schultz 2019-02-08 13:46:38 -06:00 committed by GitHub
commit 3094a64f6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -3,7 +3,8 @@
<%= render 'common/modal_header', title: 'Campaign Settings' %>
<form class='form--flatFields' autosubmit action='/nonprofits/<%=@nonprofit.id%>/campaigns/<%=@campaign.id%>' method='put' data-reload parsley-validate>
<form class='form--flatFields' autosubmit action='/nonprofits/<%=@nonprofit.id%>/campaigns/<%=@campaign.id%>' method='put' data-reload-with-slug parsley-validate>
<% if @campaign.child_campaign? %>
<div class='modal-body'>
<div class='u-margin--auto'>

View file

@ -33,7 +33,9 @@ function submit_form(form_el, on_success) {
contentType: false
})
.done(function(d) {
if(form_el.hasAttribute('data-reload'))
if(form_el.hasAttribute('data-reload-with-slug'))
window.location = d['url']
else if(form_el.hasAttribute('data-reload'))
window.location.reload()
else if(form_el.hasAttribute('data-redirect')) {
var redirect = form_el.getAttribute('data-redirect')