簡體   English   中英

使用Jquery將Textbox值附加到Summernote Textarea

[英]Appending Textbox value to Summernote Textarea using Jquery

我是使用Summernote Textarea的新手,並且在將值傳遞給summernote textarea時遇到了困難。 嘗試使用常規的.html(), .text() and .val()傳遞我的下拉列表的值,並將其附加到文.html(), .text() and .val() 這是我的一組代碼

 $("#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>

希望有人可以幫助我。 提前致謝

圖片

試試看

$( “textarea.note-可編碼”)VAL(eVariable);

解決方法如下:

 $("#btnAddVariable").click(function (e) {
       var eVariable = $("#EmailVariable option:selected").val();
       $("#EmailMessage").val(eVariable);                    
       $(".summernote").summernote('code',eVariable); //add text to summernote
       alert(eVariable);
            });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM