Advanced Page Customization Using Javascript
Users with scripting permission (issued by DonorPoint admins, contact help@donorpoint.com for access to this permission) can add HTML
You can use customary Javascript and jQuery methods in the HTML content of your Pages and Page Templates to change your DonorPoint forms. For example the ready() method in jQuery can be used to apply page customizations once the DOM is loaded.
As many DonorPoint forms use AJAX to send data to and from the browser and platform, changes that you make initially via JavScript and jQuery may be overridden during data entry. When a constituent interacts with a DonorPoint form, the data they input is sent back to the DonorPoint servers immediately. In response DonorPoint may rerender all or part of the form in the browser, overriding changes you may have made via initial Javascript and jQuery. For example changing a value on a form may cause other fields to appear or disappear based on those fields’ rules for when they are visible. If you move an element from its default location in the DOM, you may find a duplicate of the element placed back in its original location in the document. So in addition to the standard Javascript and jQuery methods, DonorPoint includes two methods related to its dynamic form rendering.
- ready(descriptor, function(element) {}) - defines a function to be called when an element matching the given descriptor is created
- observe(descriptor, function(element) {}) - defines a function to be called when an element matching the given descriptor, or elements in its DOM subtree are modified
In each case a single variable is passed to the function containing the element that was created or modified.