Reputation: 8942
I want to run some JavaScript code before modal window is shown, but when i click on button nothing happens and browser console doesn't give me any error.
<a href="#addEdgeModalB" class="btn"> EDGE </a>
<div id="addEdgeModal" class="modal hide fade">
<div class="modal-body">
<form class="form-horizontal">
<div class="control-group">
<div class="controls">
<textarea rows="3"></textarea>
</div>
</div>
<script>
$("#addEdgeModalB").on("click",function(e){
alert("click");
$("addEdgeModal").modal("show");
});
</script>
Upvotes: 1
Views: 727
Reputation: 24638
Please refer to this for the correct modal
markup.
$("a.btn").on("click",function(e){
alert("click");
});
Upvotes: 0
Reputation: 67207
Try,
$("[href='#addEdgeModalB']").on("click",function(e){
alert("click");
});
There is no id there for using id selector
here. Use attribute equals selector
at this context.
Upvotes: 2