M_Griffiths
M_Griffiths

Reputation: 581

Bootstrap modal not closing properly

I have a button that when I click it, it is supposed to close a bootstrap modal. if I use data-dismiss="modal" on the button my server side click event does not fire. when I instead use ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "success", "$('#myTreatmentModal').modal('hide');", true);

The modal goes away and my server side code fires but the darkened background put on the body by the modal does not get removed.

If you have any suggestions as to what I should do I'd definitely appreciate it.

Upvotes: 0

Views: 2235

Answers (2)

waleed hassan
waleed hassan

Reputation: 46

use jQuery.noConflict(); before model hide may be this happened due to jquery conflict

Upvotes: 0

Emiliano Montesdeoca
Emiliano Montesdeoca

Reputation: 364

Try hiding the backdrop too, this a Javascript function that hides the modal by its id and then hides the global modal backdrop.

function hideModal(id) {
  $("#" + id).modal("hide");
  $(".modal-backdrop").hide();
}

Call it from the aspx:

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "success", "hideModal('myTreatmentModal');", true);

Upvotes: 2

Related Questions