连续弹出窗口中的复选框

Checkbox in tinymce popup window

本文关键字:复选框 窗口 连续      更新时间:2023-09-26

我想使用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 "
});

    

任何帮助都将不胜感激。

一个老问题刚刚找到。如果你还在寻找答案,你可以参考他们的参考资料。这里有更多的细节

在tinymce 中有一种类型叫做checkbox

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