Search code examples
jqueryjquery-pluginsjwysiwyg

How to hide the default controls on jwysiwyg?


jwysiwyg is a plugin that converts a textarea into a HTML WYSIWG editor. I'm trying to hide the default controls it shows with their API's ControlName:{visible:false} option, but it doesn't seem to be working.

Here is the code I'm using to hide the justify controls:

function make_wysiwyg(selector, content, settings) {
    //Create the wysiwyg thingy from a given textarea
    var default_settings = {
        autoGrow: true,
        justifyLeft:{visible:false},
        justifyRight:{visible:false},
        justifyCenter:{visible:false},
        justifyFull:{visible:false}
    };
    settings = settings || default_settings;
    $(function() {
        $(selector).wysiwyg(settings).wysiwyg("setContent", content||"");
    });
}

Any ideas on why it isn't working as expected?


Solution

  • You need to place the controls inside the controls property.

        $("textarea").wysiwyg({
            rmUnusedControls: true,
            controls: {
                bold: { visible : true },
                html: { visible : true }
            }
        });
    

    Try to rewrite all the controls with rmUnusedControls from the Examples.