微小的文本对齐问题

问题描述 投票:0回答:1

我在tinymce中用空格和html编写文本描述(换行符和其他等)。然后我将其保存到mysql数据库。当我再次获取它并提醒它时,它显示的内容与以前相同。所以到现在为止它很好。 当我再次将其添加到tinymce进行编辑时,所有html和空格都消失了..可能是什么问题? 这是我的代码

 $('#description').tinymce({
                // Location of TinyMCE script
                script_url : 'tinymce/jscripts/tiny_mce/tiny_mce.js',
                // General options
                width : "825",
                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,spellchecker",
                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,spellchecker",
                spellchecker_languages : "+English=en,Russian=ru",
                // encoding : "xml",
                // Example content CSS (should be your site CSS)
                content_css : "tinymce/examples/css/content.css",

                //
                apply_source_formatting : true,

                // Replace values for the template plugin
                template_replace_values : {
                    username : "Some User",
                    staffid : "991234"
                }   
            });

这就是我如何获得价值

alert(json.description_demo);//this is ok
 $("#description").val(json.description_demo);
 alert($("#description").val());//now this is not ok..here is issue

也尝试过这个

alert(json.description_demo);//ok
tinyMCE.get('description').setContent(json.description_demo);
alert(tinyMCE.get('description').getContent());//issue not ok

图像 working notworking after value

html json tinymce
1个回答
0
投票

您必须使用

tinyMce
功能来获取和设置该值。尝试使用:

tinyMCE.get('description').getContent(); // To get the value
tinyMCE.get('description').setContent(value from db); // To set the value

查看tinymce文档

© www.soinside.com 2019 - 2024. All rights reserved.