Twitter bootstrap href modal not working
<div id="deleteModal" class="modal hide fade" tabindex="-1" role="dialog"> <div class="modal-body"> <span><i class=" icon-info-sign"></i> </div> <div class="modal-footer"> <a class="trashconfirm btn btn-info" data-dismiss="modal" href="javascript:void(0)">Yes</a> <a class="btn btn-info" data-dismiss="modal">No</a> </div> </div> I am using jquery to install hre.
$(".accordion").on('click','.dairytrash',function() { var id = $(this).closest('tr').attr('id'); var ele = $(".modal-footer .trashconfirm "); ele.attr('href','<c:url value="/delete?id='+id+'" />'); }); href also installs correctly, but when I do nothing, it happens.
+4
2 answers
If you use data-dismiss="modal" on the button (what you are doing), Bootstrap attaches a click handler to it to hide the modality if the button is pressed. This handler calls preventDefault() on the event, so any default actions (for example, those after href ) will no longer be triggered.
If you want both to call the URL when the button is pressed and hide the modal, you will need to use Javascript to attach an event handler to your button, which will call the URL and hide the modal.
+3
Use one of the event hooks described in the Bootstrap Docs ( http://twitter.imtqy.com/bootstrap/javascript.html ):
$('#myModal').on('hidden', function () { // do something⦠}) 0