MVC4,TinyMCE.MVC,在Ajax调用后无法设置tinymce控件内容

时间:2014-10-21 15:03:45

标签: ajax asp.net-mvc-4 tinymce

MVC4,下载了TinyMCE.MVC:需要通过Ajax调用检索tinymce控件的内容并设置为tinymce控件。到目前为止,我尝试在tinymce控件中设置html内容失败了。我必须使用Ajax调用。有没有办法做到这一点? 谢谢。

查看:

<div id="divTinyMCE">
    @Html.EditorFor(model => model.myContent)
</div>
<button type="button" id="btnGetContent" onclick="getContent()">Get Content</button>

@section scripts{
<script type="text/javascript">

    function getContent() {

        var parm1 = 1;
        var parm2 = 2;

        $.ajax({
            type: "POST",
            url: '/Home/GetContent',
            data: { parm1: parm1, parm2: parm2},
            success: function (data) {                    
                alert("data from ajax = " + data.toString()); // data is html

                //tinymce.set(data.toString());  // does not set anything
                //tinymce.html(data);            // does not set anything
                $("#tinymce").html(data);        // does not set anything
            }
        });  // AJAX call

    }

</script>
}     

CONTROLLER:

public ContentResult GetContent(int parm1, int parm2)
{
    string contentFound = findContent(parm1); // contentFound is HTML string
    return Content(contentFound);

}

1 个答案:

答案 0 :(得分:0)

我终于明白了:
    tinyMCE.activeEditor.setContent(数据);