[英]How to set focus on an input element in CKEditor 4?
For the link dialog I am presenting my users only a minimal dialog: 对于链接对话框,我只向用户显示一个最小对话框:
The code for this from the config.js
file: 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
}
}
Could anybody tell me how to focus the input field? 有人可以告诉我如何关注输入字段吗?
PS: I also tried to use dialogDefinition.onShow = function () { }
without success. PS:我也尝试使用dialogDefinition.onShow = function () { }
失败。
Overwrite onFocus
method in your dialog definition: 在对话框定义中覆盖onFocus
方法:
if (dialogName == 'link') {
....
dialogDefinition.onFocus = function() {
this.getContentElement( 'info', 'url' ).focus();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.