2011-12-09 9 views
1

私はCKEditorのテキストエリアを含む$ .postingなWebフォームを持っています。ポストCKEditorの内容

  1. .serialize()CKEditorバージョンの内容を取得していない:

    $(document).ready(function() { 
    
         CKEDITOR.replace('html'); 
         CKEDITOR.config.htmlEncodeOutput = true; //seems to have no effect 
    
         $('#save').click(function() {    
    
          $.post('/async.php?a=save-slide', $('#slideForm').serialize(), 
          function(json) { 
           console.log(json); 
          }, 'json'); 
         });    
        }); 
    

    は、私は2つの問題を抱えています。 I console.log シリアライズされた文字列の場合、html =は空です。

  2. CKEditorのgetData()メソッドを使用していて、POSTされたコンテンツにアンパサンド( )がある場合、XMLベースのAPI呼び出しを行うため、スクリプトが壊れます。

コンテンツを取得して安全にxmlにやさしいデータをPOSTする方法についてのアイデアはありますか?あなたの状況はループの必要がない単純である場合

var $editors = $("textarea.editor"); 
    if ($editors.length) { 
     $editors.each(function() { 
      var instance = CKEDITOR.instances[this.id]; 
      if (instance) { $(this).val(instance.getData()); } 
     }); 
    } 

答えて

1

私は戻ってそれらが結合されたテキストエリアにCKEditorバージョンの内容を移動するには、次の一般的なメソッドを使用します。

jqueryヘルパーがこの種のものに便利です。

+0

私はgetDataを使用できますが、コード化されたhtmlにする必要があり、コード内にあるconfigオプションが機能していないようです。 – doremi

+0

http://stackoverflow.com/questions/1219860/javascript-jquery-html-encoding – ScottE