suyati / line-control

A Light Weight HTML5 Text Editor designed as a JQuery Plugin
Other
124 stars 90 forks source link

How to change toolbar dynamically #86

Open navneetccna opened 7 years ago

navneetccna commented 7 years ago

I would like to add a button in toolbar which basically toggle buttons minimal to all.

Can we do that ?

My Code


$(document).ready(function() {
    $("#txtEditor").Editor();

    $("#txtEditor").Editor('createMenuItem', {"text": "TouchGlasses",
        "icon":"fa fa-arrow-down",
        "tooltip": "Touch Glasses",
        "custom": function(button, parameters){ 
            this.Editor({"bold":false});
        },
        "params": {'option1':"value1"}
        });
});

it is creating new instance of the editor

$(document).ready(function() {
    var editor = $("#txtEditor").Editor();

    editor('createMenuItem', {"text": "TouchGlasses",
        "icon":"fa fa-arrow-down",
        "tooltip": "Touch Glasses",
        "custom": function(button, parameters){ 
            editor({"bold":false});
        },
        "params": {'option1':"value1"}
        });
});

But it says : editor is not a function

gitDriesvdv commented 6 years ago

remove this: var editor = $("#txtEditor").Editor();

Try this: $("#txtEditor").Editor('createMenuItem', { "text": "TouchGlasses", "icon": "fa fa-arrow-down", "tooltip": "Touch Glasses", "custom": function (button, parameters) { $("#txtEditor").Editor({ "bold": false }); }, "params": { 'option1': "value1" } });