Documentation / Callbacks

Source

source.changed #

Arguments
html String

Triggered when the code has changed in the source view. It's input event of the source textarea.

$R('#content', {
    callbacks: {
        source: {
            changed: function(html)
            {
                // ...
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onsource: {
            changed: function(html)
            {
                // ...
            }
        }
    });
})(Redactor);

source.open #

Arguments
html String

Triggered whenever a user switch from visual mode to source code.

Callback must return html.

$R('#content', {
    callbacks: {
        source: {
            open: function(html)
            {
                // ...
                return html;
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onsource: {
            open: function(html)
            {
                return html;
            }
        }
    });
})(Redactor);

source.opened #

Triggered whenever a user switched from visual mode to source code.

$R('#content', {
    callbacks: {
        source: {
            opened: function()
            {
                // ...
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onsource: {
            opened: function()
            {
                // ...
            }
        }
    });
})(Redactor);

source.close #

Arguments
html String

Triggered whenever a user switch from source code to visual mode.

$R('#content', {
    callbacks: {
        source: {
            close: function(html)
            {
                // ...
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onsource: {
            close: function(html)
            {
                // ...
            }
        }
    });
})(Redactor);

source.closed #

Triggered whenever a user switched from source code to visual mode.

$R('#content', {
    callbacks: {
        source: {
            closed: function()
            {
                // ...
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onsource: {
            closed: function(html)
            {
                // ...
            }
        }
    });
})(Redactor);