繁体   English   中英

如何在CKEditor 4中将焦点设置在输入元素上?

[英]How to set focus on an input element in CKEditor 4?

对于链接对话框,我只向用户显示一个最小对话框:

截图

config.js文件中的代码:

CKEDITOR.on('dialogDefinition', function(ev) {
    // Take the dialog name and its definition from the event data.
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;

    // Check if the definition is from the dialog we are interested in (the 'link' dialog)
    if (dialogName == 'link') {
        // Get a reference to the 'Link Info' tab.
        var infoTab = dialogDefinition.getContents('info');
        // Remove unnecessary widgets from the 'Link Info' tab.
        infoTab.remove('linkType');
        infoTab.remove('protocol');
        infoTab.remove('browse');

        // Get a reference to the "Target" tab and set default to '_blank'
        var targetTab = dialogDefinition.getContents('target');
        var targetField = targetTab.get('linkTargetType');
        targetField['default'] = '_blank';

    // focus URL field
    // targetTab.focus(); // NOT working, function does not exist
    }
}

有人可以告诉我如何关注输入字段吗?

PS:我也尝试使用dialogDefinition.onShow = function () { }失败。

在对话框定义中覆盖onFocus方法:

if (dialogName == 'link') {
    ....
    dialogDefinition.onFocus = function() {
        this.getContentElement( 'info', 'url' ).focus();
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM