admin管理员组文章数量:1023129
this is my bootstrap modal code
<form class="form-horizontal" method="post" name="addform" id="formid">
<div id="myModal" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 id="myModalLabel">Add Question</h3>
</div>
<div class="modal-footer">
<input type="button" onClick="aj_add_question(<?=$id?>);" class="btn btn-primary" id="add_button" name="Add" value="Add Question">
<button type="button" class="btn btn" data-dismiss="modal" aria-hidden="true">cancel</button>
</div>
</div>
<div class="modal-footer">
<input type="button" value="Add Page" onclick="aj_add_page();" class="btn btn-primary" />
<button type="button" class="btn btn" data-dismiss="modal" aria-hidden="true">cancel</button>
</div>
</form>
now onclick
Add Question
i have to close current popup
then i have written code
<script>
$(document).ready(function(){
alert("Question Added..");
$('#formid').hide();
});
</script>
it will hide but get screen black
this is my bootstrap modal code
<form class="form-horizontal" method="post" name="addform" id="formid">
<div id="myModal" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 id="myModalLabel">Add Question</h3>
</div>
<div class="modal-footer">
<input type="button" onClick="aj_add_question(<?=$id?>);" class="btn btn-primary" id="add_button" name="Add" value="Add Question">
<button type="button" class="btn btn" data-dismiss="modal" aria-hidden="true">cancel</button>
</div>
</div>
<div class="modal-footer">
<input type="button" value="Add Page" onclick="aj_add_page();" class="btn btn-primary" />
<button type="button" class="btn btn" data-dismiss="modal" aria-hidden="true">cancel</button>
</div>
</form>
now onclick
Add Question
i have to close current popup
then i have written code
<script>
$(document).ready(function(){
alert("Question Added..");
$('#formid').hide();
});
</script>
it will hide but get screen black
Share Improve this question edited Feb 7 at 7:30 DarkBee 15.5k8 gold badges72 silver badges118 bronze badges asked Oct 7, 2014 at 10:08 CoderbabaCoderbaba 131 gold badge1 silver badge5 bronze badges 4-
Try close the modal as
$('#myModal').modal('hide');
– Gowri Commented Oct 7, 2014 at 10:11 - Try this: $("#modal").modal("hide"); – prava Commented Oct 7, 2014 at 10:12
-
updated my edit close the modal with model id not the form id
$('#myModal').modal('hide');
– Gowri Commented Oct 7, 2014 at 10:19 - Are oyu sure this problem is in any way related to PHP? What have you tried to resolve it? – Nico Haase Commented Jun 10, 2024 at 10:13
1 Answer
Reset to default 1I think you are not using modal popup syntax properly, can you try the following:
<div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="mymodaltitle" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
**--- put your form here**
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
Then, as others have suggested use $("#mymodal").modal('hide')
this is my bootstrap modal code
<form class="form-horizontal" method="post" name="addform" id="formid">
<div id="myModal" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 id="myModalLabel">Add Question</h3>
</div>
<div class="modal-footer">
<input type="button" onClick="aj_add_question(<?=$id?>);" class="btn btn-primary" id="add_button" name="Add" value="Add Question">
<button type="button" class="btn btn" data-dismiss="modal" aria-hidden="true">cancel</button>
</div>
</div>
<div class="modal-footer">
<input type="button" value="Add Page" onclick="aj_add_page();" class="btn btn-primary" />
<button type="button" class="btn btn" data-dismiss="modal" aria-hidden="true">cancel</button>
</div>
</form>
now onclick
Add Question
i have to close current popup
then i have written code
<script>
$(document).ready(function(){
alert("Question Added..");
$('#formid').hide();
});
</script>
it will hide but get screen black
this is my bootstrap modal code
<form class="form-horizontal" method="post" name="addform" id="formid">
<div id="myModal" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 id="myModalLabel">Add Question</h3>
</div>
<div class="modal-footer">
<input type="button" onClick="aj_add_question(<?=$id?>);" class="btn btn-primary" id="add_button" name="Add" value="Add Question">
<button type="button" class="btn btn" data-dismiss="modal" aria-hidden="true">cancel</button>
</div>
</div>
<div class="modal-footer">
<input type="button" value="Add Page" onclick="aj_add_page();" class="btn btn-primary" />
<button type="button" class="btn btn" data-dismiss="modal" aria-hidden="true">cancel</button>
</div>
</form>
now onclick
Add Question
i have to close current popup
then i have written code
<script>
$(document).ready(function(){
alert("Question Added..");
$('#formid').hide();
});
</script>
it will hide but get screen black
Share Improve this question edited Feb 7 at 7:30 DarkBee 15.5k8 gold badges72 silver badges118 bronze badges asked Oct 7, 2014 at 10:08 CoderbabaCoderbaba 131 gold badge1 silver badge5 bronze badges 4-
Try close the modal as
$('#myModal').modal('hide');
– Gowri Commented Oct 7, 2014 at 10:11 - Try this: $("#modal").modal("hide"); – prava Commented Oct 7, 2014 at 10:12
-
updated my edit close the modal with model id not the form id
$('#myModal').modal('hide');
– Gowri Commented Oct 7, 2014 at 10:19 - Are oyu sure this problem is in any way related to PHP? What have you tried to resolve it? – Nico Haase Commented Jun 10, 2024 at 10:13
1 Answer
Reset to default 1I think you are not using modal popup syntax properly, can you try the following:
<div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="mymodaltitle" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
**--- put your form here**
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
Then, as others have suggested use $("#mymodal").modal('hide')
本文标签: javascriptHow to close the modal popupStack Overflow
版权声明:本文标题:javascript - How to close the modal popup? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745594120a2158060.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论