SummerNote insertHtml [英] SummerNote insertHtml

查看:87
本文介绍了SummerNote insertHtml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个模板"选择器,使人们可以更改当前文本区域的"text/html".

I have a 'template' selector, that enables people to change the 'text/html' of the current textarea.

因此,当他们更改模板时,我需要更新Summernote HTML.我看到(insertText)的方法,但不适用于HTML.

So when they change templates, I need to update the Summernote HTML. I see the method for (insertText), but it doesn't work for HTML.

是否有HTML版本的解决方案?

Is there a solution for HTML version?

我认为有一个.code()解决方案,但似乎没有用吗? 我收到错误消息不是功能"

I thought there was a .code() solution, but doesn't seem to be working? I receive an error, "Not a function"

任何帮助将不胜感激!

$('.dialogMessageArea').summernote({
            height:'230px',
            focus:true,
            toolbar: [
                ['style', ['bold', 'italic', 'underline', 'clear']],
                ['fontsize', ['fontsize']],
                ['para', ['ul', 'ol', 'paragraph']],
                ['table', ['table']],
                ['misc', ['fullscreen','undo','redo']]
            ]
        });

        $(document).on('change', '.messageTemplate', function() {
            var templateId = $(this).selected().attr('value');
            if(templateId) {
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: '/cont/templates/GetTemplate',
                    data: {'templateId': templateId},
                    success: function (data) {
                        $('.subjectMessage').val(data.results[0].subject);
                        if(data.results[0].template) {
                            $('.dialogMessageArea').code(data.results[0].template);
                        }
                    },
                    error: function () {
                        alert('We were not able to get your template');
                    }
                });
            }
        });


console.log($('.dialogMessageArea'));
console.log("<b>Welcome</b><h3>hello world</h3>");

推荐答案

根据api(要更改所见即所得的值,您应该使用summernote函数,并将代码"字符串作为第一个参数,将内容作为第二个参数

to change wysiwyg's value you should use summernote function with 'code' string as first parameter and your content as second one

喜欢这个:

$('.dialogMessageArea').summernote('code', data.results[0].template);

这篇关于SummerNote insertHtml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆