Javascript 捕获bootrstrap模式对话框中的复选框更改
我需要捕捉局部视图中作为引导模式对话框呈现的复选框更改。我试着用Javascript 捕获bootrstrap模式对话框中的复选框更改,javascript,jquery,model-view-controller,bootstrap-modal,Javascript,Jquery,Model View Controller,Bootstrap Modal,我需要捕捉局部视图中作为引导模式对话框呈现的复选框更改。我试着用 $(".modal input:checkbox").change(function () { $(".modal input:checkbox").attr("checked", false); $(this).attr("checked", true); }); 没有运气 这是一种观点: @model List<MyModel> <div class="modal-header">
$(".modal input:checkbox").change(function () {
$(".modal input:checkbox").attr("checked", false);
$(this).attr("checked", true);
});
没有运气
这是一种观点:
@model List<MyModel>
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
<h4 class="modal-title"></h4>
</div>
@using (Html.BeginForm("DoSomething", "MyController", FormMethod.Post, new { @class = "form-horizontal", role = "form"}))
{
<div class="modal-body">
<table class="table borderless">
@for (int i = 0; i < Model.Count; i++)
{
<tr>
<td>
@Html.HiddenFor(item => item[i].Id)
</td>
<td>
@Html.CheckBoxFor(item => item[i].Checked)
</td>
<td>
@Html.TextBoxFor(item => item[i].Title, new { @style = "border: none; width: 100% " })
</td>
<td>
@Html.TextBoxFor(item => item[i].Desc, new { @style = "border: none; width: 100% " })
</td>
</tr>
}
</table>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Close</button>
</div>
}
@型号列表
×
@使用(Html.BeginForm(“DoSomething”,“MyController”,FormMethod.Post,new{@class=“form horizontal”,role=“form”}))
{
@for(int i=0;iitem[i].Id)
@Html.CheckBoxFor(item=>item[i]。已选中)
@Html.TextBoxFor(item=>item[i].Title,新{@style=“border:none;width:100%”)
@Html.TextBoxFor(item=>item[i].Desc,新的{@style=“border:none;width:100%”)
}
接近
}
对话框通过主视图中的actionlink调用 模态是使用ajax渲染的吗?javascript在哪里加载?因为它是一个局部视图,所以我认为您需要在这里加载。。所以,试试
$('document')。在('change',“.modal input:checkbox”,function(){
…我不知道我在registed*.js中调用js的背后使用了什么引导,函数调用是$(function(){$('body')。在('click','modal link',function(e){e.preventDefault();$(this).attr('data-target','modal container')$(this).attr('data-toggle','modal');$('body')。on('click','modal-close-btn',function(){$('.#modal-container')。modal('hide');});$('modal-container')。on('hidden.bs.modal',function(){$(this.removeData('bs.modal');});});@GuruprasadRao尝试过,它不起作用