简体   繁体   English

加载Bootstrap Wysiwyg编辑器内容

[英]Loading Bootstrap Wysiwyg editor content

Found this Save and Load Bootstrap Wysiwyg editor content . 找到这个保存并加载Bootstrap Wysiwyg编辑器内容 but loading does not work as suggested. 但加载不符合建议。

Created http://jsfiddle.net/vNPAJ/28/ 创建了http://jsfiddle.net/vNPAJ/28/

jQuery jQuery的

jQuery(document).ready(function ($) {            
            $("#t1").wysihtml5();
            $("#b1").click(function () {
                $("#t2").val($("#t1").val());                
            });
            $("#b2").click(function () {
                $("#t1").val($("#t2").val());
            });
        });

HTML HTML

<textarea style="width:570px" id="t1">Test <b>Data</b></textarea><br /><br />
<textarea id="t2"style="width:570px"></textarea><br /> <br />
<button class="btn-primary" id="b1" type="button">Get</button>
<button class="btn-primary" id="b2" type="button">Set</button>

Get is working fine. 得到的工作正常。

On clicking set button I want to fill editor with source from 2nd textarea. 在点击设置按钮时,我想用第二个textarea的源代码填充编辑器。

Not sure how to do this... 不知道怎么做...

Upon researching your issue. 在研究你的问题。 It seems that you need to use a hack in order to populate the value in wysihtml5() since it includes iframe 看来你需要使用hack来填充wysihtml5()的值,因为它包含iframe

Try doing this, i added a line in #bt2 that set value to #t1 尝试这样做,我在#bt2中添加了一行,将值设置为#t1

jQuery(document).ready(function ($) {            
            $("#t1").wysihtml5();
            $("#b1").on('click',function () {
                $("#t2").val($("#t1").val());                
            });
            $("#b2").on('click',function () {

                $("#t1").parent('body').find('iframe').contents().find('.wysihtml5-editor').html('I changed!');
            });
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM