0

ajax 応答を介してコンテンツを wp_editor に挿入しています。ドロップダウンから編集したいレコードを選択すると、編集したいすべてのフィールドに入力されます。これにより、改行なしで wp_editor コンテンツが挿入されます。改行を手動で追加して保存すると、問題なく保存され、コンテンツが正しく表示されます。しかし、次にそのアイテムを編集しようとすると、改行なしでエディターに挿入されるため、手動で改行を再度追加する必要があります。

これは、wp_editor を作成するために使用しているものです。

$args = array(
 'textarea_rows' => 15,
 'textarea_name' => 'customEditor',
 'media_buttons' => false
);

wp_editor( '', 'customEditor', $args );

これは、ajax 応答からエディターにコンテンツを挿入する方法です。

tinyMCE.get( "customEditor" ).setContent(result[i].services);

また、エディターに挿入するときに引用符と単一引用符をエスケープしています。これは ajax レスポンス json エンコードによるものかもしれないと感じています。そのため、編集者に送信する前に、このコンテンツで何かをする必要があると考えています. これを処理する解決策を知っている人はいますか?

コンソールで ajax 応答がどのように見えるかを次に示します。

"services":"Here is a link <a href=\\\"http:\/\/www.example.com\\\">http:\/\/www.example.com<\/a>\r\n\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line\r\nthis is a new line"

次のようにエディターに挿入されます

Here is a link <a href="\&quot;example.com\&quot;">example.com</a>; this is a new line this is a new line this is a new line this is a new line this is a new line this is a new line this is a new line this is a new line this is a new line this is a new line this is a new line this is a new line
4

0 に答える 0