在tinymce弹出窗口中的复选框

3

我想在使用tinymce的弹出窗口中创建复选框。我可以在弹出窗口中创建列表框,但无法在其中创建复选框。

var tempGroups = ['Group1', 'Group2', 'Group3', 'Group4'];

var temp = [{
    group: 'Group1',
    title: 'Title1',
    content: '<p>Content1</p>',

 }, {
    group: 'Group1',
    title: 'Title1-1',
    content: '<p>Content11</p>',

 }, {
    group: 'Group2',
    title: 'Title2',
    content: '<p>Content2</p>'

 }, {
    group: 'Group2',
    title: 'Title2-1',
    content: '<p>Content22</p>'
 }, {
    group: 'Group3',
    title: 'Title3-1',
    content: '<p>Content33</p>'
 }, {
    group: 'Group4',
    title: 'Title4',
    content: '<p>Content4</p>'
 }, {
    group: 'Group4',
    title: 'Title4-1',
    content: '<p>Content44</p>'
 }];

var tempGroupName;
var menuItems = [];

function createTempMenu(editor) {
    for (i = 0; i < tempGroups.length; i++) {
        var tempArray = [];
        tempArray[i] = [];
        tempGroupName = tempGroups[i];
        for (j = 0; j < temp.length; j++) {
            if (temp[j].group == tempGroupName) {

                tempArray[i].push({

                    text: temp[j].title,
                    content: temp[j].content,
                    //  type: 'checkbox',

                    onclick: function () {
                        alert(this.settings.content);
                    }
                });

            }
        }
        menuItems[i] = {

            text: tempGroupName,
            menu: tempArray[i],


        };
    }
    return menuItems;
}



tinymce.init({
    selector: "textarea",
    setup: function (editor) {
        editor.addButton('button', {
            type: 'menubutton',
            text: 'button',
            icon: false,

            menu: [
                {
                    text: 'Customer List',
                    onclick: function () {

                        editor.windowManager.open({
                            title: 'Customer Name',
                            width: 200,
                            height: 100,

                            items: [
                                {
                                    type: 'listbox',
                                    value: 0,
                                    label: 'Section: ',
                                    values: createTempMenu(editor),
                                    body: [
                                        {
                                            type: 'checkbox',
                                            label: 'Section: ',
                                            // text: "new",
                                            values: createTempMenu(editor),


                                                        }],

                                    onsubmit: function (e) {
                                        
                                    }
                                                }]
                        });
                    }
                            }]

        });
    },
    toolbar: " button "
});


    

非常感谢您的帮助。

1个回答

0

发现一个老问题。如果你仍在寻找答案,可以参考他们的参考资料这里,其中有更多细节。

Tinymce 中有一种叫做复选框的类型。

                    {
                        type   : 'checkbox',
                        name   : 'choose the name',
                        label  : 'choose a label',
                        text   : 'the text near the checkbox',
                        checked : false
                    },

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接