如题,代码如下
<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");
}
我该怎么得到这个编辑器里的内容,求指导
UE.getEditor('editor').getContent()
去这里看http://ueditor.baidu.com/doc/ 提交到后台的时候不要忘了对ueditor的内容校验
UE.getEditor('editor').getContent() 这个放在哪啊 是要在上面写一个JS吗?然后传过去? 我是个小白 希望多多指导
@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>
@秋壶冰月: 谢谢,我试试
参考一下这个你就明白了 http://www.tzwhx.com/NewShow/newBodyShow/AJAX_35873.html
好的,我去看看,谢谢