Redactor / Documentation / API


Overview #

This jQuery plugin initializes Redactor and provides access to API.

Launching Redactor


With class or any selector:


On launch, plugin returns jQuery object or objects (if plugin has been applied to multiple elements on a page)

Redactor can be launched with certain settings. Settings are passed as JavaScript object:

    focus: true,
    initCallback: function()

External access to API

Although Redactor provides the ability to access API externally, we strongly recommend you to always create a plugin for API access. This makes code nicer, simpler and logically accurate.

For external API access, you can pass a string with function name to the plugin:


All API functions are part of different modules; first, set module's name, and then provide an API function (separated from module's name by a dot.)

For example, to get HTML code from Redactor, let's set 'code' module and 'get' function:

var html = $('#content').redactor('code.get');

API calls can return data. If plugin has been applied to multiple elements on a page, data will be returned as an array, for example

var arrayHtml = $('.content-class').redactor('code.get');

When calling an API function, you can also pass an argument to it:

$('#content').redactor('code.set', '<p>My html code</p>');

Multiple arguments can be passed, if a function accepts multiple arguments.