Callbacks

On this page:

    inLine comes with the following callback functions.


    onChange

    The onChange callback is excecuted each time you make a change on the selector initialized with inLine. It must be specified on the main options as shown below and it returns the API object:

    How to set

    new inLine('#myEditor', { 
    onChange: function (api) {
    document.querySelector('#myTextarea').value = api.content;
    }
    });

    onToolbarOpen

    The onToolbarOpen callback is excecuted when you select a text and the toolbar comes up.

    How to set

    new inLine('#myEditor', {
    onToolbarOpen: function (api) {
    console.log('The text you selected is ' + api.selection.text;
    }
    });

    onToolbarClose

    The onToolbarClose callback is excecuted when you release the selection and the toolbar is closed.

    How to set

    new inLine('#myEditor', {
    onToolbarClose: function (api) {
    console.log('The toolbar has been closed');
    }
    });

    onDestroy

    The onDestroy callback is excecuted when you call the destroy function and the selector is restored to the default state:

    How to set

    new inLine('#myEditor', {
    onDestroy: function () {
    console.log('Inline function has been destroyed');
    }
    });

    onReady

    The onReady callback is excecuted when inLine is successful initialized and everything is ready to go.

    How to set

    new inLine('#myEditor', {
    onReady: function (api) {
    console.log('Inline is ready');
    }
    });