Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyMCE adding multiple custom toolbar button

Tags:

tinymce

I'm following the tutorial on http://tinymce.moxiecode.com/tryit/custom_toolbar_button.php but need to add multiple custom buttons.

Here is my block for adding one button, but I need to add more than one button and don't know how

setup : function(fn) {
    // Add a custom button
    fn.addButton('firstname', {
        title : 'Member First Name',
        image : 'resources/scripts/tiny_mce/themes/advanced/img/firstname.gif',
        onclick : function() {
            // Add you own code to execute something on click
            fn.focus();
            fn.selection.setContent('{firstname}');
        }
    });
}

Thanks for your help

like image 619
drhoo Avatar asked Dec 18 '25 16:12

drhoo


1 Answers

Just call fn.addButton multiple times:

setup : function(fn) {
    // Add a custom button
    fn.addButton('firstname', {
        title : 'Member First Name',
        image : 'resources/scripts/tiny_mce/themes/advanced/img/firstname.gif',
        onclick : function() {
            // Add you own code to execute something on click
            fn.focus();
            fn.selection.setContent('{firstname}');
        }
    });
    fn.addButton('lastname', {
        title : 'Member Last Name',
        image : 'resources/scripts/tiny_mce/themes/advanced/img/lastname.gif',
        onclick : function() {
            // Add you own code to execute something on click
            fn.focus();
            fn.selection.setContent('{lastname}');
        }
    });
}

If you are defining the toolbar layout, eg

toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | firstname",

remember to add the new id (eg. lastname)

like image 195
Dr.Molle Avatar answered Dec 21 '25 04:12

Dr.Molle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!