Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Modal doesn't close

HTML:

<div id="im_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="Image" aria-hidden="true">
    <div class="modal-footer">
        <a type="button" class="btn pull-left" href="javascript:close_preview()">Cancel</a>
        <button type="submit" class="btn btn-primary pull-left">OK</button>

Javascript:

function close_preview() {
    $("#im_modal").modal("hide");
}

The function close_preview is being called, but doesn't close the modal.

like image 883
user2653179 Avatar asked Nov 18 '25 16:11

user2653179


1 Answers

It should work, probably the positioning of the function close_preview is not where it is supposed to be. But there is another way without using any methods/events you can add data-dismiss attribute to the button.

<a type="button" class="btn pull-left" data-dismiss="modal">Cancel</a>

Fiddle

like image 142
PSL Avatar answered Nov 20 '25 07:11

PSL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!