javascript - CKEDITOR 对话框 - 单击按钮打开第二个选项卡

标签 javascript ckeditor

我有带有两个选项卡的 CKEDITOR 对话框: - 查看一个 - 查看两个

在 View 一内,我有一个按钮,如果用户单击该按钮,应打开 View 二。

enter image description here

但我不知道该怎么做。这是我的 CKEDITOR.dialog 代码:

CKEDITOR.dialog.add('placeholder', function(editor) {
    var lang = editor.lang.placeholder,
        generalLabel = editor.lang.common.generalTab,
        validNameRegex = /^[^\[\]<>]+$/;

    return {
        title: 'some title',
        minWidth: 300,
        minHeight: 150,
        contents: [{
            id: 'initial-view',
            label: 'view one',
            title: generalLabel,
            elements: [{
                id: 'name-one',
                style: 'width: 100%;',
                type: 'html',
                html: 'Organizational units'
            }, {
                type: 'button',
                id: 'buttonId',
                label: 'Click me',
                title: 'My title',
                setup: function(widget) {

                    },
                onClick: function(widget) {
                    // this = CKEDITOR.ui.dialog.button
                    My code should go here........?
                }
            }]
        }, {
            id: 'organizational-unit-view',
            label: 'view two',
            title: generalLabel,
            elements: [
                // Dialog window UI elements.
                {
                    id: 'list-of-vars',
                    style: 'width: 100%;',
                    type: 'html',
                    html: 'second view --- html goes here',
                    label: lang.name,
                    setup: function(widget) {
                        this.setValue(widget.data.name);
                    },
                    commit: function(widget) {
                        widget.setData('name', this.getValue());
                    }
                }
            ]
        }]
    };
});

我的问题是我应该如何处理按钮点击?我应该使用什么方法?基本上如何打开 View 二?

最佳答案

我找到了解决方案。点击事件应该使用 getDialog():

 this.getDialog().selectPage('your-content-id);

像这样:

onClick: function(widget) {
    this.getDialog().selectPage('organizational-unit-view');
}

关于javascript - CKEDITOR 对话框 - 单击按钮打开第二个选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42370590/

相关文章:

javascript - Firebase 未定义。 super 可修复,但修复不起作用。 Hello World 示例

Javascript `replace` 替换后备

javascript - 正则表达式:从可能包含多个 '{' 和 '}' 的字符串中提取子字符串

css - 网页 css 覆盖 ckeditor 3 样式

javascript - CKEditor图像插件配置

javascript - 输入字段为空时显示/隐藏 div(jquery,javascript)

javascript - 在具有 getElementsByTagName() 的对象上添加 'mouseover' 和 'mouseout' 事件监听器仅将事件应用于最后一项

javascript - jquery 如何隐藏被点击的单个 html 对象?

iframe - ckeditor不读取媒体嵌入代码

php - 防止 PyroCMS 从所见即所得内容中剥离内联样式?