Php tinymcs中的Jquery文本问题
我有一个简单的问题,我有一个文本区域,我在jquery中为它分配文本。这是带有一些行空格的纯文本。这里是一个文本示例Php tinymcs中的Jquery文本问题,php,jquery,tinymce,Php,Jquery,Tinymce,我有一个简单的问题,我有一个文本区域,我在jquery中为它分配文本。这是带有一些行空格的纯文本。这里是一个文本示例 Brand new!!! Huge size of 3 bedroom apartment located in Dubai Marina Orra tower for rent Situated on high floor, overlooking a gorgeous view of Marina 现在,当我分配到textarea时,它和上面一样 $("#descrip
Brand new!!!
Huge size of 3 bedroom apartment located in Dubai Marina Orra tower for rent
Situated on high floor, overlooking a gorgeous view of Marina
现在,当我分配到textarea时,它和上面一样
$("#description").val(val);//val is above text
现在当我使用tinymce时,它变成这样
Brand new!!! Huge size of 3 bedroom apartment located in Dubai Marina Orra tower for rent Situated on high floor, overlooking a gorgeous view of Marina
空间线打破一切失去的。
这是我的tinymce代码
$().ready(function() {
$('#description').tinymce({
// Location of TinyMCE script
script_url : 'application/views/tinymce/jscripts/tiny_mce/tiny_mce.js',
// General options
width : "830",
height: "300",
theme : "advanced",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_toolbar_location : "top",
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,bullist,numlist,",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
force_br_newlines : true,
force_p_newlines : false,
gecko_spellcheck : true,
forced_root_block : '', // Needed for 3.x
plugins : "paste"
});
});
为什么我的文本会变形?在JSFIDLE中,您在JQuery之后附加了tinyMCE。没用,我已经修好了。 正如你在评论中看到的,这个问题是正确的。麻烦的核心–
\n
换行符到
转换。您可以自己完成此操作,替换以下内容:
$("#description").val(val)
为此:
$("#description").val( val.replace( /\n/, '<br />' ) );
$(“#description”).val(val.replace(/\n/,“
”);
您是否尝试过:tinyMCE.activeEditor.setContent('HTML')
?我到目前为止还没有得到任何答案……如果您在中直接设置值,会出现什么问题呢?val()
tinyMCE将不会解析它。它在任何情况下都不起作用