Custom Javascript

Adding custom javascript code

When working with Forms it may be required to use javascript to animate forms and perform certain actions. JEditor allows you to add custom Javascript code that will be executed on page load.

To add javascript code to your Jira pages do the following:

  1. Go to JEditor Configuration > Custom Javascript
  2. Insert the code into the Javascript field
  3. Save

The code will be executed every time when you reload the page.

Please note: You don't need to wrap your code into the <script> tags in the Custom Javascript field.

Executing code when Jira updates a page without reloading it

Jira doesn't always reload the page when you navigate issues, update fields, etc.

If you need your code to be executed every time Jira reloads data (for example when a user navigates to another issue in a queue or edits and saves a field), you may want to add a listener that executes a callback every time when Jira fires a corresponding event. = || {}; = function(message) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {
if (reason === 'pageLoad' || reason === 'issueTableRowRefreshed') {
require('jeditor-helpers').proxy.cooldown(, null, 1000)('some text');

In this example: is a namespace for custom functions.

myFunc is a sample name of your function, you can give it any name. You can also define your function using var myFunc.

When JIRA loads any new data into the view, it triggers the NEW_CONTENT_ADDED event. This event is fired every time when, for example, a user selects another ticket in a queue. However, the event may be fired multiple times.

require('jeditor-helpers').proxy.cooldown is a JEditor API function that prevents other functions from being called more often than once within a given interval of time.

To avoid calling myFunc multiple times you can use this proxy function to add a "cooldown" period (in this example, 1000 milliseconds). The null parameter is for an editor instance which is not needed in this example.

Notice how a text parameter 'some text' is passed to myFunc through the proxy function. You may use this approach to pass any number of arguments.

Have more questions? Submit a request


Article is closed for comments.
Powered by Zendesk