Note that there are some explanatory texts on larger screens.

plurals
  1. POTwitter Bootstrap: close modal wait for close and open a new one
    text
    copied!<p>I'm working on a project with Twitter Bootstrap. It consists of a single html page, and, with the help of jQuery, I fetch data and pages from server.<br> I have a unique modal for the whole project and I append data in the body everytime I show it. My problem is that when i close the modal and re-open it with new content, javascript stops working and no modal is opened. If i add some delay between closing and opening it works on some browsers but doesn't on others(chrome for example) and the code is really ugly.<br> I think I should bind an event when the modal is closed before opening a new one. Here's my code for opening a modal: </p> <pre><code>function apriModal(header, messaggio, callback, conferma) { var re = new RegExp("&lt;/?\w+\s+[^&gt;]*&gt;"); $("#modalHeaderTitle").text(header); if (messaggio.match(re)) { $("#modalBodyText").html(messaggio); } else { $("#modalBodyText").html("&lt;p&gt;" + messaggio + "&lt;/p&gt;"); } (!conferma) ? $("#modalConfirm").hide() : $("#modalConfirm").show(); $("#finestraModal").modal('show') $("#modalConfirm").off().click(function () { if (conferma) { $("#finestraModal").modal('hide') conferma(); } }); $("#modalClose").show(); $("#modalClose").off().click(function () { if (callback) { callback(); } $("#finestraModal").modal('hide'); }); } </code></pre> <p>Here's a little example: <a href="http://jsfiddle.net/thetom/nqNzr/15/" rel="nofollow">http://jsfiddle.net/thetom/nqNzr/15/</a><br> If you need more info ask. Thank you so much in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload