提问人:Shahriar 提问时间:10/4/2023 更新时间:10/4/2023 访问量:22
不要在不刷新的情况下一次获取弹出表单
Don't get the pop-up form more the one time without refreshing
问:
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
@* <h5 class="modal-title" id="exampleModalLabel">Modal title</h5> *@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<--- My Form Loads Here ---->
<div class="modal-body" id="partial_view_div">
</div>
</div>
</div>
</div>
</div>
<div>
<button id="CreateAirportForm">Create New</button>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$('body').on('click', '#CreateAirportForm', function (event) {
LoadNewAirport();
});
function LoadNewAirport() {
$('#exampleModal').modal('show');
$.ajax({
type: "GET",
url: '@Url.Action("LoadNewAirportForm", "Airports")',
data: {},
success: function (data) {
$('#partial_view_div').html(data);
},
error: function (xhr, ajaxOption, thrownError) {
alert("An error occurred while loading the partial view.");
}
});
}
</script>
第一次按下“新建”按钮后,弹出表单工作正常。但是第二次它不起作用。如果我刷新我的页面,那么它第一次可以正常工作,但第二次就不起作用了。
我怎样才能解决这个问题。我想在按下“新建”按钮时多次获取弹出表单。
答: 暂无答案
评论
id
CreateAirportForm
<form id=CreateAirportForm>
<div id=partial_view_div>
$('#exampleModal').modal('show');
console.log($('[id=exampleModal]').length)