Reputation: 401
I have used a bootstrap modal dialog that is opened by clicking button. When I click on button at the first time,modal is opened; by the second clicking, modal dialog does not show and this error is shown in firebug consol:
TypeError: $(...).modal is not a function
$(".bs-modal-dialog").modal();
how can i solve that? thanks...
these are my code:
<div class="modal fade bs-modal-dialog" id="modalDialog" tabindex="-1" role="dialog"
aria-labelledby ="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button class="close" aria-hidden="true" data-dismiss="modal" type="button">×</button>
<h4 id="mySmallModalLabel" class="modal-title"></h4>
</div>
<div class="modal-body">
</div>
</div>
</div>
<script>
function EditCompany(CoId) {
var link="@Url.Action("EditCompany", "Companies", new { area = "AdminsArea", CoId = "-1"})";
link=link.replace("-1",CoId);
$(".bs-modal-dialog").modal('show');
$(".modal-body").load(link);
$(".modal-content > .modal-header> #mySmallModalLabel").text("Edit Company");
}
<input type="button" name="EditCompany" value="Edit" onclick="EditCompany(@co.CompanyID)" class="btn btn-success"/>
Upvotes: 8
Views: 10334
Reputation: 4649
You don't need any JavaScript to do that, Bootstrap already comes with html attribute for that.
All you have to do this include data-toggle="modal" data-target="#myModal"
and it should trigger your modal.
Upvotes: 4