Documentation

Autosave

autosave

Type: Boolean String

Default: false

This setting turns on autosave feature. In Redactor, autosave works seamlessly in background and saves every change in text.

Setting requires server script URL as an argument:

$R('#content', {
    autosave: '/myadmin/content/save/'
});

Data will be passed to the server script using POST method, textarea variable will contain all the content. Here's a PHP example:

echo $_POST['textareaname'];

The name of textarea variable can be changed via autosaveName setting.

autosaveName

Type: Boolean String

Default: false

Sets POST variable name for the variable to be passed to the autosave script:

$R('#content', {
    autosave: '/myadmin/content/save/',
    autosaveName: 'my-content-name'
});

autosaveData

Type: Boolean Object

Default: false

This setting allows you to send additional POST params to your autosave script.

$R('#content', {
        autosave: '/myadmin/content/save/',
        autosaveData: {
            id: 10,
        elements: '#my-input-1, #my-input-2, #my-form'
    }
});

The example above shows how to send POST params with autosaving. The data object has key=value params, including values in the input and form fields if the additional object has key elements with field and form selectors.

The values of the input and form fields are appended as values: field-name: value.

autosaveMethod

Type: String

Default: post

With this setting, you can change the method of sending a request.

$R('#entry', {
    autosave: '/myadmin/content/save/',
    autosaveMethod: 'put'
});