Documentation

Migrate to Atlassian Connect JavaScript V5

The Atlassian Connect JavaScript library has been updated to version 5. In this version we have overhauled and deprecated a lot of existing methods that were considered redundant.

You should update your JavaScript to use the new syntax as deprecated methods are no longer supported and will be removed after August 2017.

AMD: require and define

AP.require and AP.define has been deprecated in this version of Atlassian Connect JavaScript API. The available modules can now be called directly from AP, such as AP.request or AP.jira. No alternative will be provided for AP.define.

Old syntax

AP.require(['request', 'dialog'], function (request, dialog) {
    request({
        url: '/rest/api/content/123',
        success: function (data) {
            dialog.create({
                key: 'add-dialog-key',
                customData: {
                    contentData: data
                }
            });
        }
    });
});

New syntax

AP.request({
    url: '/rest/api/content/123',
    success: function (data) {
        AP.dialog.create({
            key: 'add-dialog-key',
            customData: {
                contentData: data
            }
        });
    }
});

If you have used AP.define, it recommended that you use another library such almond.js or require.js instead.

Messages

The Messages module has been deprecated and the Flag module should be used instead.

Old syntax using Messages

AP.require("messages", function(messages){
    var message = messages.info('plain text title', 'plain text body');
});

New syntax using Flag

var flag = AP.flag.create({
    title: 'plain text title',
    body: 'plain text body',
    type: 'info'
});

Dialog

customData

Dialog's static customData member has been deprecated and has been replaced with the getCustomData(callback) method.

Old syntax using customData

AP.require('dialog', function(dialog){
    var myDataVariable = dialog.customData.myDataVariable;
});

New syntax using getCustomData(callback)

AP.dialog.getCustomData(function (customData) {
    var myDataVariable = customData.myDataVariable
});

onDialogMessage()

The onDialogMessage() method has been deprecated and the AP.events module should be used instead.

Old Syntax using onDialogMessage()

AP.require('dialog', function(dialog){
    dialog.onDialogMessage('submit', function() {
        console.log('dialog submitted!');
    });
});

New syntax using Events.on()

AP.events.on('dialog.submit', function () {
    console.log('dialog submitted!');
})

Dialog.on()

The Dialog.on() method has been deprecated and the AP.events module should be used instead.

Old syntax using Dialog.on()

AP.require('dialog', function(dialog){
    dialog.create(opts).on("close", function() {
        console.log('dialog closed!');
    });
});

New syntax using Events.on()

AP.events.on('dialog.close', function () {
    console.log('dialog closed!');
});

DialogButton.bind()

The DialogButton.bind() method has been deprecated the AP.events module should be used instead.

Old syntax using DialogButton.bind()

AP.require('dialog', function(dialog){
    dialog.getButton('submit').bind(function(){
        alert('clicked!');
    });
});

New syntax using Events.on()

AP.events.on('dialog.submit', function () {
    console.log('dialog submitted!');
})