{"id":8008,"date":"2015-11-20T05:42:04","date_gmt":"2015-11-20T05:42:04","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/20\/twitter-bootstrap-modal-backdrop-doesnt-disappear-open-source-projects-jschr-bootstrap-modal\/"},"modified":"2022-08-30T15:03:04","modified_gmt":"2022-08-30T15:03:04","slug":"twitter-bootstrap-modal-backdrop-doesnt-disappear-open-source-projects-jschr-bootstrap-modal","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/20\/twitter-bootstrap-modal-backdrop-doesnt-disappear-open-source-projects-jschr-bootstrap-modal\/","title":{"rendered":"Twitter bootstrap modal-backdrop doesn&#39;t disappear-open source projects jschr\/bootstrap-modal"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/graph.facebook.com\/1116126353\/picture?type=large\" \/> <strong>Bill Huertas<\/strong><\/p>\n<p>I just spent way too long on this problem \ud83d\ude42<\/p>\n<p>While the other answers provided are helpful and valid, it seemed a little messy to me to effectively recreate the modal hiding functionality from Bootstrap, so I found a cleaner solution.<\/p>\n<p>The problem is that there are a chain of events that happen when you call<\/p>\n<pre><code>$(\"#myModal\").modal('hide');\nfunctionThatEndsUpDestroyingTheDOM()\n<\/code><\/pre>\n<p>When you then replace a bunch of HTML as the result of the AJAX request, the modal-hiding events don&#8217;t finish. However, Bootstrap triggers an event when everything is <strong>finished<\/strong>, and you can hook into that like so:<\/p>\n<pre><code>$(\"#myModal\").modal('hide').on('hidden.bs.modal', functionThatEndsUpDestroyingTheDOM);\n<\/code><\/pre>\n<p>Hope this is helpful!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bill Huertas I just spent way too long on this problem \ud83d\ude42 While the other answers provided are helpful and valid, it seemed a little messy to me to effectively recreate the modal hiding functionality from Bootstrap, so I found a cleaner solution. The problem is that there are a chain of events that happen [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8008","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8008","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8008"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8008\/revisions"}],"predecessor-version":[{"id":8702,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8008\/revisions\/8702"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}