Last active
January 31, 2017 18:00
Star
You must be signed in to star a gist
HTML and script to use when adding a "donation.Note" field to a donation page. We need to use a technique like this because notes fields are typically text areas. Salsa uses text areas to edit fields. A text area cannot contain another text area (that's an HTML rule) or the editor gets very badly confused.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
// Add a donation.Note field to the form in a fieldset. | |
// @See https://help.salsalabs.com/hc/en-us/articles/115000001253 | |
document.addEventListener("DOMContentLoaded", function () { | |
var noteFieldset = document.querySelector('#note-fieldset'); | |
if (noteFieldset == null) return; | |
var marker = document.querySelector('#need-donation-note'); | |
if (marker == null) return; | |
var beforeSelector = marker.getAttribute('before'); | |
if (beforeSelector == null) { | |
marker.appendChild(noteFieldset); | |
} else { | |
target = document.querySelector(beforeSelector); | |
target.parentNode.insertBefore(noteFieldset, target); | |
} | |
}); | |
</script> | |
<div style="display: none;"> | |
<fieldset id="note-fieldset"> | |
<legend></legend> | |
<div class="formRow" id="donation-not-label-row"> | |
<label for="donation-note"> | |
Let us know what you think. | |
</label> | |
</div> | |
<div id="note-row" class="formRow"> | |
<textarea name="Note" id="donation-note"></textarea> | |
</div> | |
</fieldset> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment