0

I am using the Twitter Bootstrap Modal dialog to upload an image asynchronously. When I upload an image this function is called:

$("#upload-btn").click(function () {
        var options = {
            beforeSubmit:  showRequest,
            success:       showResponse
        };

        function showRequest(formData, jqForm, options) {
            $("#upload-btn").html('<i class="fa fa-refresh fa-spin"></i> Uploading...');
            return true;
        }

        function showResponse(responseText, statusText, xhr, $form)  {
            $("#uploadModal").modal('hide');

            $("#upload-btn").html('Upload');
            if (responseText != "OK"){
                notify(responseText);
            }
            $("#file_to_upload").val('');
            loadImages();
        }

        $("#uploadForm").ajaxSubmit(options);
        return false;
    });

This question is a duplicate of this other question: Twitter bootstrap modal-backdrop doesn't disappear

But after I tried to implement every solution offered there, I decided to open a new question because none of the answers worked in my case:

I tried adding this after I hide my modal:

$('#uploadModal').modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();

It actually makes modal-backdrop disappear but when I tried to upload a new image again, Bootstrap modal doesn't open. So I tried adding the removed classes again when clicking #upload-btn but this makes .modal-backdrop appear again blocking my view.

Any help would be appreciated.

Community
  • 1
  • 1
Diego Vidal
  • 1,022
  • 12
  • 21

0 Answers0