title: prevent bootstrap modal close on click outside
body: <p>I want to prevent closing bootstrap modal if user clicks outside modal or press ESC. I know this question was asked many times, but they didn't help</p>
  
  <p>my modal</p>
  
  <pre><code>&lt;div class="modal fade modal-popup confirm-uploaded-image-popup" id="uploadedImagePopup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"&gt;
     &lt;div class="modal-dialog modal-popup-content" role="document"&gt;
      &lt;div class="confirm-uploaded-image-popup-img"&gt;&lt;/div&gt;
      &lt;div class="modal-popup-desc"&gt;{!! trans("You have uploaded a picture. Are you sure you want to add it to your gallery?") !!}&lt;/div&gt;
      &lt;button class="btn btn-very-light-gray confirm-uploaded-image-popup-cancel"&gt;{{ trans('Cancel') }}&lt;/button&gt;
      &lt;button class="btn btn-green confirm-uploaded-image-popup-ok"&gt;{{ trans('OK') }}&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>modal appears after file has been uploaded(from form).</p>
  
  <pre><code>window.showRegisteruploadConfirmPopup = function(regupload, okCallback, cancelCallback){
  
  var $popup = $('#uploadedImagePopup');
  var $popupImg = $popup.find('.confirm-uploaded-image-popup-img');
  var $okBtn = $popup.find('.confirm-uploaded-image-popup-ok');
  var $cancelBtn = $popup.find('.confirm-uploaded-image-popup-cancel');
  //use a boolean flag to avoid successive popups calling previous popup's callbacks
  //this variable is separate for each popup
  $popupImg.css('background-image', 'url(' + regupload['path'] + ')');
  window.lastReguploadId = regupload['id'];
  //these handlers are attached to the same element, so prevent multiple handlers from multiple uploads
  $okBtn.on('click', function(){
      //only execute callback if it's still the same element, not overriden by a new upload
      if(window.lastReguploadId == regupload['id']){
          okCallback.call(window);
          $popup.hide();
      }
  });
  $cancelBtn.on('click', function(){
      //only execute callback if it's still the same element, not overriden by a new upload
      if(window.lastReguploadId == regupload['id']){
          cancelCallback.call(window);
          $popup.hide();
      }
  });
  
  $popup.modal("show");
  
  }
  </code></pre>
  
  <p>I've already lots of variants, for example <code>$popup.modal('show', {backdrop: 'static', keyboard: false;</code> also setting attributes to modal element <code>&lt;div class="modal fade modal-popup confirm-uploaded-image-popup" data-backdrop="static" data-keyboard="false"&gt;</code> but nothing works. </p>