Skip to content

Instantly share code, notes, and snippets.

@salsalabs
Last active January 31, 2017 18:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save salsalabs/fbf4e63fd2fb1ba3511e8e15fc998263 to your computer and use it in GitHub Desktop.
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.
<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