Honestly I have dig deep here and seen something similar to what am looking for, but none of them seems to work for me. I know am missing it somewhere, somehow.
My challenge is that I have a button link on clicking performs a validation check and if the no error is found, i want to trigger a modal window.
below are my code sample
Preview
onclicking the button the javascript function runs very well, but i have not been able to get the modal to load when error < 1. Please help
<script>
function validate_radiobutton_group(form){
var error = 0;
if(error>0){
alert("........");
return false;
}
else{
$('#myModal').modal({
show: true
});
}
}
</script>
<div aria-hidden="false" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" class="modal fade" id="myModal" style="width: 640px;">
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
<h3 id="myModalLabel"></h3>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-primary">Close</button>
</div>
</div><!--#myModal-->
According to the documentation , to show the modal you call:
$('#myModal').modal('show');
instead of:
$('#myModal').modal({
show: true
});
Check the markup for your modal
I created a plunker with modal markup from bootstraps docs and it works as expected. http://plnkr.co/edit/vyCL7WqQ014X6wJ8AUjw?p=preview
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.