我有这样的观点
@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")] [@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);
});
但是每当我点击复选框时都没有任何反应。我做错了什么
答案 0 :(得分:0)
替换
$('#MessageRecipients').val($(this).val);
与
$('#MessageRecipients').val($(this).val());