I created a bootstrap model popup when I tried to open it via jQuery, I got this following error “Uncaught TypeError: f[b] is not a function” and a bootstrap model popup is not opening.
Code:
<script type="text/javascript">
$(function () {
$("#btnShow").click(function () {
$('#demoModal').modal('open');
});
});
</script>
<div style="text-align: center; margin-top: 10%">
<button id="btnShow" class="btn btn-primary btn-lg">Show Modal Popup</button>
</div>
<!--Modal -->
<div class="modal fade" id="demoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" 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>
<h4 class="modal-title" id="myModalLabel">Bootstrap Modal Popup</h4>
</div>
<div class="modal-body">content goes here..</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btnbtn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Solution:
Previously, I used the wrong syntax to open a bootstrap model popup, next I correct it and open jQuery bootstrap popup like this, $('#demoModal').modal('Show');.