2010-02-03 53 views
21

我使用最新的CKeditorjQuery adapter如何使用jQuery適配器將配置信息傳遞給CKEditor?

我已經成功地將它工作並顯示出來。

然而,當我完全新的CKEDITOR,我怎麼傳中使用jQuery的方法配置變量?

這是我有

$('#input-content').ckeditor('', { 
    toolbar: 'basic' 
}); 

我想從我讀過,第一個參數,就是要回調,第二個的配置。但是這樣做並沒有改變編輯器。

如何使用these config properties等使用jQuery適配器?

回答

12

我通過一個空的功能...

$('textarea#my').ckeditor($.noop, { 
    property: 'value' 
}); 
+0

刪除;來自:'價值'; – EmRa228 2012-05-05 09:17:02

2
var config = { 
    toolbar: 
    [ 
     ['Source','-','Save','NewPage','Preview','-','Templates'], 
     ['Maximize', 'ShowBlocks','-','About'] 
    ], 
    coreStyles_bold: { element : 'b', overrides : 'strong' } 
}; 

只需添加相應的配置對象,上述予添加coreStyles_bold,我所做的是改變「=」從CK API文檔到「:」

2
$(document).ready(function(){ 
    $('.reply').click(
    function(event){ 
     // Event click Off Default 
     event.preventDefault(); 
     // CKEditor 
     $(function(){ 
      var config = {toolbar:[['Bold', 'Italic', '-', 'Link', 'Unlink']]}; 
      //<?php /*echo"var config = {toolbar:[['Bold', 'Italic', '-', 'Link', 'Unlink']]};" ;*/ ?> 
      // DOM class = "cke" 
      $('textarea.cke').ckeditor(function(){}, config);     
     }); 
     return false; 
    }); 
}); 
19

我已經使用此代碼完成了此操作。希望這有助於。

下面是HTML:

<textarea id="txtMessage" class="editor"></textarea> 

這裏是JavaScript:

try { 
     var config = 
      { 
       height: 180, 
       width: 515, 
       linkShowAdvancedTab: false, 
       scayt_autoStartup: true, 
       enterMode: Number(2), 
       toolbar_Full: [['Styles', 'Bold', 'Italic', 'Underline', 'SpellChecker', 'Scayt', '-', 'NumberedList', 'BulletedList'], 
           ['Link', 'Unlink'], ['Undo', 'Redo', '-', 'SelectAll']] 

      }; 

     $('textarea.editor').ckeditor(config); } 
+1

這對我有用 – 2013-09-12 11:22:23

8
jQuery(function(){ 
     var config = { 
      toolbar: 
      [ 
       ['Bold', 'Italic', 'Underline', '-', 'NumberedList', 'BulletedList', '-', 'Undo', 'Redo', '-', 'SelectAll'], 
       ['UIColor'] 
      ] 
     };  
     jQuery('#textAreaElement').ckeditor(config); 
    }); 
1

不知道這是CKEDITOR的一項新功能,但只是想分享我的解決辦法(以防萬一尋找此現象):

$("textarea.youreditor").ckeditor 
(
    { 
     customConfig: "/path/to/custom/config.js" 
    } 
); 

...和我的配置是這樣的(簡單複製默認的config.js):

CKEDITOR.editorConfig = function(config) 
{ 
    config.toolbar_Full = 
    [ 
     { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] }, 
     { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'] }, 
     { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] }, 
     { name: 'colors', items : [ 'TextColor','BGColor' ] } 
    ]; 
};  
0

有它的官方文檔,看jQuery Adapter

的CKEditor的()方法接受兩個可選參數:

  • 編輯器準備就緒時執行的回調函數。
  • 具體到編輯器中創建實例配置選項:
 
    $('textarea').ckeditor({ 
     uiColor: '#9AB8F3' 
    });