0

我有这样的看法

@Html.Partial("_validationSummary")
 <div class="row-fluid">
    <div class ="span8 well">
        @using (Html.BeginForm("Send", "Message", FormMethod.Post) ) {
    <fieldset>
    <legend>Send SMS Message</legend>
      <div class="editor-label text-info">
       <small>Recipients phone numbers here.</small>
    </div>
    <div class="editor-field">
        @Html.TextAreaFor(model => model.MessageRecipients, new { @class = "span8", rows=3 })

    </div>

       <div class="editor-label text-info">
       <small>Select from your contact listings =>.</small>
    </div>
    <div class="editor-field">
        @Html.TextAreaFor(model => model.ContactRecipients, new { @class = "span8", rows=3, @readonly=true })
    </div>

     <div class="editor-label text-info">
       <small> Your Message Here:</small>
    </div>
    <div class="editor-field">
        @Html.TextAreaFor(model => model.Message, new { @class = "span8", rows = 5})

        <br />
        <span class="text-warning" id="char_count"></span><br />
    </div>

    <div class="editor-label text-info"><small>
      Send Message As:</small>
    </div>
    <div class="editor-field">
        @Html.TextBoxFor(model => model.MessageSentAS)

    </div>
   <br />

    <p> <input type="submit" class="btn btn-primary btn-medium" Value="Send" name="Action" />
        <button role="button" class="btn btn-medium" data-target="#timeModal" data-toggle="modal">Send Later</button>
    </p>
</fieldset>
        } 
  </div>

 <div id="ContactList" class="span4 well" >
    <span class="label label-important">Select From Contact List</span>
    <hr />
   @* @Html.Partial("_ContactsForMessageViewPartial", Model)*@
        @Html.Action("RenderContacts");

    <hr />
    <div class="control-group">
        [@Html.ActionLink("Send Bulk SMS", "Send", "BulkMessaging")] &nbsp;[@Html.ActionLink("Add Contact", "AddContact", "Contact")]
    </div>


</div>

以及从子操作填充数据的部分视图

@model IEnumerable<TwiiterSample.Models.ViewModels.SMSContactView>

@if (Model != null && Model.Count() > 0)
{
foreach(var item in Model){
    <div class="checkbox multiple">

        @Html.CheckBox(item.ContactDetails, new {@class="check",     @value=@item.ContactDetails, id=@item.ContactDetails})
          @Html.Label(item.Name)
   @*<input type="checkbox" id="@item.Value"  value="@item.Value" @(item.Selected ?     "checked" : "") />@item.Text</label>*@
    </div>
}
}

现在,部分视图会生成一个复选框列表,其中包含根据需要填充的 IDS 和 VALUES。但是,如果将复选框单击到文本区域,我想附加它的值。我使用以下 JQUERY 片段来实现这一点

$('#ContactList .check').change(function ()
  {
      if ($(this).is(':checked'))
          $('#MessageRecipients').val($(this).val);

  });

但是,每当我单击复选框时,什么都没有发生。我究竟做错了什么

4

1 回答 1

0

replace

$('#MessageRecipients').val($(this).val);

with

$('#MessageRecipients').val($(this).val());
于 2013-03-24T11:10:15.310 回答