2014-02-20 123 views
0

對於鏈接對話框我提出我的用戶只有一個最小的對話框:如何設置焦點的輸入元件上的CKEditor 4?

Screenshot

代碼這個從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() { }沒有成功。

回答

1

覆蓋onFocus方法在對話框的定義:

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

它的工作原理,謝謝。我仍然認爲我們需要一個大的教程網頁提供很多的CKEditor配置的例子,像這樣的。 –

相關問題