首页 新闻 搜索 专区 学院

MVC+ueditor用异步怎么得到ueditor 里面的内容

0
悬赏园豆:10 [已解决问题] 解决于 2015-01-28 09:05

如题,代码如下

<div id="divAdd">
@using (Ajax.BeginForm("AddMember", "Member", new { }, new AjaxOptions() { HttpMethod = "post", OnSuccess = "afterAdd" }, new { id = "addForm" }))
{
<table>
<tr><td>标题</td><td><input type="text" name="title" data-options="required:true" class="easyui-validatebox textbox" style="width:50%" /></td></tr>
<tr><td>URL</td><td><input type="text" name="href" style="width:50%" /></td></tr>
<tr>
<td>详细内容:</td>
<td>
<script id="editor" type="text/plain" style="width:1024px;height:500px;">
</script>
<script type="text/javascript">
var ue = UE.getEditor('editor');
</script>
</td>
</tr>
</table>
}
</div>

这里有一个

<script type="text/javascript">
var ue = UE.getEditor('editor');
</script>

MVC里面

public ActionResult AddMember(Member member)
{
member.title = Request["title"];
member.href = Request["href"];
member.add_time = DateTime.Now;
db.Member.Add(member);
db.SaveChanges();
return Content("ok");
}   

我该怎么得到这个编辑器里的内容,求指导

xk123的主页 xk123 | 初学一级 | 园豆:195
提问于:2015-01-27 13:41
< >
分享
最佳答案
0
 UE.getEditor('editor').getContent()  

去这里看http://ueditor.baidu.com/doc/  提交到后台的时候不要忘了对ueditor的内容校验

收获园豆:10
秋壶冰月 | 大侠五级 |园豆:5663 | 2015-01-27 13:55

UE.getEditor('editor').getContent()   这个放在哪啊  是要在上面写一个JS吗?然后传过去? 我是个小白   希望多多指导

xk123 | 园豆:195 (初学一级) | 2015-01-27 14:00

@xk123: 

<!DOCTYPE html>
<html>
<head>
    <title>ueditor</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
</head>
<body>
    <div id="container">
        <table style="width: 100%;" class="doc-table">
            <tr>
                <td>
                    内容
                </td>
                <td>
                    <div style="text-align:left;">
                        <script id="editor" type="text/plain" style="width: 1000px; height: 400px;">
                        </script>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;">
                    <input type="button" id="btnSave" value="发布" onclick="getPlainTxt();" />
                </td>
            </tr>
        </table>
    </div>
    <script type="text/javascript" charset="utf-8" src="/Content/js/jquery.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/Content/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/Content/js/ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="/Content/js/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript">
        UE.getEditor('editor');
        function getPlainTxt() {
            var content = UE.getEditor('editor')
                            .getContent()
                            .replace(/\[b\]([^\[]*?)\[\/b\]/igm, '<b>$1</b>')
                            .replace(/\[i\]([^\[]*?)\[\/i\]/igm, '<i>$1</i>')
                            .replace(/\[u\]([^\[]*?)\[\/u\]/igm, '<u>$1</u>')
                            .replace(/\[url=([^\]]*)\]([^\[]*?)\[\/url\]/igm, '<a href="$1">$2</a>')
                            .replace(/\[img\]([^\[]*?)\[\/img\]/igm, '<img src="$1" />');
            alert(content);
            $.ajax({
                type: "post",
                url: '',  //提交到后台
                data: {
                    "content": content
                },
                success: function (msg) {
                    alert(msg);
                }
            });
        }
    </script>
</body>
</html>
秋壶冰月 | 园豆:5663 (大侠五级) | 2015-01-27 14:16

@秋壶冰月: 谢谢,我试试

xk123 | 园豆:195 (初学一级) | 2015-01-27 14:34
其他回答(1)
0

参考一下这个你就明白了 http://www.tzwhx.com/NewShow/newBodyShow/AJAX_35873.html

竹林溪风 | 园豆:225 (菜鸟二级) | 2015-01-27 14:07

好的,我去看看,谢谢

支持(0) 反对(0) xk123 | 园豆:195 (初学一级) | 2015-01-27 14:16
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册