我在数据插件交换器(Remark组件引导程序)中遇到了问题,该问题不想在partialviews中工作。有趣的是,如果它停留在普通视图内,则可以正常工作,但是当放置在由局部视图打开的模态窗口(#modalGeneric)内时,它将不起作用:
在PartialView中(问题):
@model Retaguarda.Application.ViewModels.ContatoTipo.ContatoTipoViewModel
@{
ViewData["Title"] = "_ContatoTipo";
}
<div class="panel">
<div class="panel-body container-fluid pt-10 pl-15 pr-15">
<div class="form-horizontal">
<vc:summary />
<div class="form-horizontal">
<div class="form-group row">
<div class="col-md-6">
<label asp-for="Descricao" class="control-label">Descrição</label>
<input asp-for="Descricao" class="form-control text-uppercase" />
<span asp-validation-for="Descricao" class="text-danger"></span>
</div>
</div>
<div class="example">
<div class="float-left mr-20">
<input type="checkbox" id="mycheckbox" name="inputiCheckBasicCheckboxes" data-plugin="switchery"
checked />
</div>
<label class="pt-3" for="inputBasicOn">On</label>
</div>
</div>
</div>
</div>
</div>
<script>
$('#mycheckbox').switchery({
switcheryParent: $('#modalGenerica')
});
</script>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
Layout.cshtml:
<div class="modal fade modal-primary" id="modalGenerica" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div id="contentModal">
</div>
</div>
</div>
</div>
我尝试在Partialview中给出一个替代,但是没有用。我认为缺少某些内容,或者脚本有问题。
<script>
$('#mycheckbox').switchery({
switcheryParent: $('#modalGenerica')
});
</script>