defineTemplateAction

defineTemplateAction Method

Description

If you implement a custom template service, the defineTemplateAction method enables you to define a custom action that can be applied to diagram templates displayed in the template selection window of the editor. Each custom action you define will result in a new action button displayed under the template preview area of the template selector. Up to 3 template actions may be defined.

.defineTemplateAction( /*String*/ label, /*Function*/ actionFunction)

Parameters

label String

A string that will be used as the label of the action button.

actionFunction Function

A function that accepts two parameters.

This function will be called when the user invokes the template action.

Note: only 3 template actions may be defined. Attempting to add more than 3 will result in an exception.

This method must be used before the startup method is called. defineTemplateAction will throw an exception if called after startup.

Example

editor = new window.__editor(undefined, document.getElementById('editor-node'));
 
editor.defineTemplateAction('Delete', function (templateId, refresh) {
    // Delete template server-side via an ajax request.
    ...
    // refresh the template manager window
    refresh();
});
 
// Startup the editor with templateServiceUrl enabled.
editor.startup({
    ...
    templateServiceUrl: 'http://www.example.com/REST/'
});