c# - JSON TinyMCE 返回值 "\t"

标签 c# javascript asp.net-mvc json tinymce

我应该为“streszczenie”使用另一个变量吗?或者我应该怎么做?

在我看来,TinyMCE 正文中有 html,但我只得到 "\t" 可能我遇到了 JS 问题

this is new problem - this question is related with this link. I added this for other users

这是我用TinyMCE写的

enter image description here

这是我从 TinyMCE textarea "streszczenie"得到的

enter image description here

如您所见,有文字 ghhfgh 但我无法获取此文字

enter image description here

现在我在执行 JSON 时遇到了问题

<script type="text/javascript">

    function Save() {
        tinyMCE.triggerSave();
        var Temat_controll = $('#Temat').val();
        var Streszczenie_controll = tinyMCE.get('Streszczenie').getContent();
        var PelnyOpis_controll = $('#PelnyOpis').text();

            $.ajax({
                url: '@Url.Action("DodajTematSave", "StronaGlowna")',
                dataType: "json",
                data: { 
                    Temat: Temat_controll,
                    Streszczenie: Streszczenie_controll,
                    PelnyOpis: PelnyOpis_controll
                },
                type: "POST",
                async: false,
                error: function() {
                },
                success: function(data) {
                    if (data.Success) {
                        alert('success');
                    }

                }
            });
        }

</script>

我明白了,但是 JSON 一直没有执行

enter image description here

当我点击按钮 tinyMCE.get('Streszczenie').getContent() 为空时,我检查了这个,但我不知道为什么,因为我已经将文本放入文本区域

<script type="text/javascript">

    function Save() {
        var Temat_controll = $('#Temat').val();
        var $d = tinyMCE.get('Streszczenie').getContent();
        if ($d.length != 0) {
            if ($d.val().length != 0) {
                var Streszczenie_controll = tinyMCE.get('Streszczenie').getContent();
            }
            else {
                var Streszczenie_controll = 'ewewe';
            }
        }
        var PelnyOpis_controll = $('#PelnyOpis').text();

        $.ajax({
            url: '@Url.Action("DodajTematSave", "StronaGlowna")',
            dataType: "json",
            data: {
                Temat: Temat_controll,
                Streszczenie: Streszczenie_controll,
                PelnyOpis: PelnyOpis_controll
            },
            type: "POST",
            async: false,
            error: function () {
            },
            success: function (data) {
                if (data.Success) {
                    alert('success');
                }

            }
        });
    }

</script>

最佳答案

您以错误的方式获取内容,而不是通过 jQuery 的 val()

要获取 tinymce 内容,只需使用 tinyMCE 对象引用:

// Get the HTML contents of the currently active editor
console.debug(tinyMCE.activeEditor.getContent());

// Get the raw contents of the currently active editor
tinyMCE.activeEditor.getContent({format : 'raw'});

// Get content of a specific editor:
tinyMCE.get('content id').getContent()

如前所述: http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.getContent

希望它有所帮助。波兰人:)

关于c# - JSON TinyMCE 返回值 "\t",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15598341/

相关文章:

javascript - 如何将 if 转换为 while

c# - 在模型中声明列表

asp.net-mvc - 有没有办法用 HTML 5 数据属性创建 ActionLink?

c# - 用于 C# SlimDX 游戏 UI 的内容

c# - 使用动态枚举作为方法参数中的类型

c# - 更新在 OwnsMany 值对象关系 EF Core 5 中不起作用

asp.net-mvc - 在特定列而不是整个网格上使用 settings.CellEditorInitialize

c# - 在数据库 mvc2 c# 4.0 中存储时以字节为单位减少图像

javascript - 声云波形

javascript - 如何修改 OHLC 图表中条形图的默认颜色?