2

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-->

2 Answers 2

2

According to the documentation, to show the modal you call:

$('#myModal').modal('show');

instead of:

$('#myModal').modal({
   show: true
});
1
  • Thanks bingjie2680 for your responses, but i tried that too and it didn't work
    – Gifto
    Commented Mar 23, 2014 at 17:45
0

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

2
  • Thanks Remento, I just tested my entire code on the plunker and it worked perfectly well, but it is still not working on my local machine. Don't know why.
    – Gifto
    Commented Mar 23, 2014 at 19:40
  • Not sure why, perhaps a the version of bootstrap is different? The markup in the example is for the 3.x version. May also want to check your network tab in the console to make sure that the bootstrap JS and CSS files are being included on your page.
    – Remento
    Commented Mar 24, 2014 at 1:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.