我正在使用来自Tinymce编辑器的富文本发送邮件并显示但是我在javascript中调试时出现以下错误 无法阅读财产' getContent'未定义的
这是我的代码 //模型
public class EmailModel
{
public int Id { get; set; }
public string Sender { get; set; }
public string Receiver { get; set; }
public string SubjectText { get; set; }
[AllowHtml]
[UIHint("tinymce_full_compressed")]
[Display(Name = "BodyText")]
public string BodyText { get; set; }
public string AboutMe { get; set; }
}
public class EmailListModel
{
public List<EmailModel> ListEmailModel { get; set; }
public EmailModel EmailModel { get; set; }
}
//视图
@model StarRatingControl.Models.EmailListModel
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "EmployeeMail";
}
<h2>EmployeeMail</h2>
<div class="form-horizontal">
<h4>About</h4>
<hr />
@Html.ValidationSummary(true)
<div class="form-group">
@Html.LabelFor(model => model.EmailModel.SubjectText, new { @class = "col-md-12" })
<div class="col-md-12">
@Html.EditorFor(model => model.EmailModel.SubjectText, new { @style = "width:790px;" })
@Html.ValidationMessageFor(model => model.EmailModel.SubjectText)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.EmailModel.BodyText, new { @class = "col-md-12" })
<div class="col-md-12">
@Html.EditorFor(model => model.EmailModel.BodyText)
@Html.ValidationMessageFor(model => model.EmailModel.BodyText)
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" id="sendMail" value="Create" class="btn btn-default" />
</div>
</div>
</div>
// JS
$("#sendMail").click(function () {
$('#' + 'BodyText').html(tinymce.get('BodyText').getContent());
var subject = $("#SubjectText").val();
var body = $("#BodyText").val();
var data = {
subject: subject,
body: body
};
alert(body);
$.post('@Url.Action("SendEmpMail", "ManageEmployee")', data, function (res) {
if (res)
{
alert('Mail Sent Successfully');
}
});
});
重要的一点是,当我在视图中使用EmailModel时,一切工作正常,但由于显示我使用了EmailListModel。使用此模型后,我没有获得值。
答案 0 :(得分:0)
import org.apache.spark.{SparkConf, SparkContext}
import com.datastax.spark.connector._
val conf = new SparkConf().setMaster("local[2]).setAppName("test")
.set("spark.cassandra.connection.host", "192.168.0.1")
val sc = new SparkContext(conf)
val files = sc.textFiles("hdfs://192.168.0.1:9000/test/", 1)
files.map(_.split("\n")).saveToCassandra("ks", "tb", SomeColumns("id", "time", "text"))
sc.stop()
命令要求您传递TinyMCE替换的tinymce.get()
的ID。如果你看到......
<textarea>
...然后你的Cannot read property 'getContent' of undefined
命令不正确。所以问题就变成了这段代码:
tinymce.get()
在浏览器中创建?底层@Html.EditorFor(model => model.EmailModel.BodyText)
的ID是多少?一旦您知道可以使用<textarea>
命令来定位该编辑器实例。