Custom scripting

You may add your custom Javscript code to any Docxpresso Template.

This is thought so you can add custom behaviours to the end user interface that may have not been foreseen by Docxpresso developers or simply because they are particular for an specific template.

You may do so from the Docxpresso backoffice interface:

  1. Go to the general template processing interface by clicking in the selected document.
  2. Click the Process Web Interface or Process Web form button.
  3. Within the corresponding processing interface click on the "code" button on the top menu and choose Custom Javascript code from the dropdown menu.
  4. Insert the vanilla Javascript code or JQuery code (check in the browser the used JQuery version to make sure that your code is compatible) that you want to run on document ready (no need to extra test for that).
  5. Hit the save button and afterwards save all template changes.

Docxpresso will insert your code on the preview interface and if there are no errors it should run together with the rest of the standard Docxpresso javascript functions and actions.

For example, the following code will warn the user that he has chosen a certain option:

$('span[data-name]').on('click', 'input[name="accept"]', function(){
  if ($(this).val() == 'no'){
    toastr.error('Are you sure you want to accept the conditions?', 'Warning');
  }
});

This particular sample code checks for the value of a radio button element, present in the template and associated with the "accept" variable, and warns the user, using toastr (an external JS library already preloaded by Docxpresso) that he is not accepting certain conditions established in that particular document.