CKEDITOR对话框 - 按下按钮打开第二个选项卡

时间:2017-02-21 14:50:54

标签: javascript ckeditor

我有两个标签的CKEDITOR对话框: - 查看一个 - 查看两个

在内部视图中,我有一个按钮,如果用户点击,则应打开视图2。

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());
                    }
                }
            ]
        }]
    };
});

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

1 个答案:

答案 0 :(得分:0)

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

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

像这样:

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