[英]Prevent Parent page from reloading when exit button is clicked in popup
I have created a popup using modal. 我已经使用模式创建了一个弹出窗口。 When user clicks on a link it will show this modal popup. 当用户单击链接时,它将显示此模式弹出窗口。 I have put an exit button inside popup in order to close the popup. 我已经在弹出窗口中放置了退出按钮以关闭弹出窗口。 My problem is when i click on the exit button, the popups exits but the parent page gets reloaded. 我的问题是,当我单击退出按钮时,弹出窗口退出,但父页面被重新加载。
Is there any way to preventing the parent page from reloading. 有什么方法可以防止父页面重新加载。
Here is the code for modal popup: 这是模式弹出窗口的代码:
<div id="box-config-modal1" class="modal hide fade in" style="display: none;">
<div class="box" id="box-details">
<h4 class="box-header round-top">Details</h4>
<div class="box-container-toggle" style="padding-left:20px;padding-right:20px;">
<div class="box-content">
<form name="popup" id="popup">
<fieldset>
<button class="close" data-dismiss="modal"></button>
<h3>User Details</h3>
<div class="control-group">
<div class="controls">
<label class="control-label" for="typeahead" style="width:100px;float:left;">Name </label><label id="advname" style="padding-left:150px;"></label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="control-label" for="typeahead" style="width:100px;float:left;">ID </label><label id="advid" style="padding-left:150px;"></label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="control-label" for="typeahead" style="width:100px;float:left;">Email </label><label id="email1" style="padding-left:150px;"></label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="control-label" for="typeahead" style="width:100px;float:left;">Country </label><label id="country" style="padding-left:150px;"></label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="control-label" for="typeahead" style="width:100px;float:left;">Website </label><label id="website" style="padding-left:150px;"></label>
</div>
</div>
<div class="control-group">
<div class="controls" id="newlist">
<label class="control-label" for="typeahead" style="width:100px;float:left;">Change
History </label><label id="changehistory" style="padding-left:150px;"></label></div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
Since your <form>
doesn't have any submit button, so browser treating that button as submit button. 由于您的<form>
没有任何提交按钮,因此浏览器将该按钮视为提交按钮。
So use this code 所以用这个代码
<button class="close" data-dismiss="modal" onclick="javascript:return false;"></button>
OR put this button outside <form>
Tag 或将此按钮放在<form>
标签之外
I assume, you are using bootstrap modal. 我认为,您正在使用引导程序模式。
You can create custom button to close bootstrap modal. 您可以创建自定义按钮以关闭引导程序模式。 Just check the following code 只需检查以下代码
<a href="#" class="my-close-btn">Close Popup</a>
$(function () {
$(".my-close-btn").on('click', function() {
$('#box-config-modal1').modal('hide');
return false;
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.