我是使用Summernote Textarea的新手,我很难在summernote textarea上传递价值。尝试使用传统的.html(), .text() and .val()
来传递我的下拉列表的值并将其附加到textarea中。这是我的代码集
$("#btnAddVariable").click(function (e) {
var eVariable = $("#EmailVariable option:selected").val();
$("#EmailMessage").val(eVariable);
$("#EmailMessage").text(eVariable);
alert(eVariable);
})
我的下拉
<div class="form-group">
@Html.LabelFor(model => model.EmailVariable, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-6">
@Html.DropDownListFor(model => model.EmailVariable, new SelectList(ViewBag.emailVariables, "Value", "Text"), "Please Select", htmlAttributes: new { @class = "form-control" })
@* @Html.DropDownList(model => model.EmailVariable, new SelectList(ViewBag.emailSender, "Value", "Text"), "Please Select", htmlAttributes: new { @class = "form-control" })*@
</div>
<div class="col-md-2">
<input type="button" id="btnAddVariable" value="Add Variable" class="btn btn-primary chosen" />
</div>
</div>
和我的Summernote Textarea
<div class="form-group">
@Html.LabelFor(model => model.EmailMessage, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-8">
<div class="ibox-content no-padding">
@Html.TextAreaFor(model => model.EmailMessage, new { @class = "summernote", rows = "5", cols = "90" })
</div>
</div>
</div>
希望有人可以帮助我。在此先感谢
答案 0 :(得分:1)
尝试
$( “textarea.note-可编码”)VAL(eVariable);
答案 1 :(得分:0)
以下是解决方案:
$("#btnAddVariable").click(function (e) {
var eVariable = $("#EmailVariable option:selected").val();
$("#EmailMessage").val(eVariable);
$(".summernote").summernote('code',eVariable); //add text to summernote
alert(eVariable);
});