Q:

Bootstrap 3 nested modals – backdrop z-index and close modal on click

I’m working on a web application (Asp.Net MVC 5) where the user has to crate many data records with mappings to other records. The user must be able to create a mapping to an existing or newly created record.
A typical case would be the creation of an address:

User opens the site to create an address
He enters the normal fields like street and street no etc.
He can select an existing city (in which the address is located) from a table
If the required city does not already exist he can create a new city
… For the city, he can select a country or create on (same as for address and city)

The selection is implemented using bootstrap modals.
Pressing on a select button (like select city) shows a modal containing a table showing all the selectable records in a table.
The modal with the table contains an add new button to add new entities, which opens another modal.
To be able to reuse the views I’ve split the code in partial views like this:

_CreateAddress => Contains only the form to create an address
_CreateAddressModal => A modal containing _CreateAddress
_SelectAddressModal => A modal containing a table to showing all addresses. The modal contains also _CreateAddressModal which will be displayed when the user clicks on the add new button
_CreateCity => Contains only the form to create a city
_CreateCityModal => A modal containing _CreateAddressModal
_SelectCityModal => A modal containing a table to showing all cities. The modal contains also _CreateCityModal which will be displayed when the user clicks on the add new button

…and so on
I’ve two problems:

Clicking on a backdrop does not close the open modal
The backdrop of the topmost modal has a lower z-index than the all other modals and does therefore not hide the other modals

I’ve tried to set the z-index of the backdrops on modal show, to make sure they hide the other modals but this didn’t work => the backdrops get displayed above the current modal.
Here is a fiddle showing the problem:  jsFiffle
SO does not let me link to a JSFiddle without adding the code to the question, so here is the code: 
HTML:
<!-- Create Address -->
<div id="CreateAddress" class="modal fade fullScreen" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">Create Address</h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-info">
                              <strong>Placeholder</strong> Here is the form to create an address
                    <button class="btn btn-default" id="selectCityButton">select city</button>
                        </div>
                <button class="btn btn-primary">OK (not implemented)</button>
                <button class="btn btn-default modalCloseButton"
                        data-modalid="CreateAddress">Cancel</button>
            </div>
        </div>
    </div>
</div>

<!-- Select City -->
<div id="SelectCity" class="modal fade fullScreen" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">Select a City</h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-info">
                              <strong>Placeholder</strong> Here is a table to select an existing city
                        </div>
                <button class="btn btn-success btn-block" id="createCityButton">Create new city</button>
                <button class="btn btn-primary">OK (not implemented)</button>
                <button class="btn btn-default modalCloseButton"
                        data-modalid="SelectCity">Cancel</button>
            </div>
        </div>
    </div>
</div>

<!-- Create City -->
<div id="CreateCity" class="modal fade fullScreen" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">Create City</h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-info">
                              <strong>Placeholder</strong> Here is the form to create a city
                    <button class="btn btn-default" id="selectCountryButton">select country of city</button>
                        </div>
                <button class="btn btn-primary">OK (not implemented)</button>
                <button class="btn btn-default modalCloseButton"
                        data-modalid="CreateCity">Cancel</button>              
              <!-- Select Country -->
              <div id="SelectCountry" class="modal fade fullScreen" tabindex="-1" role="dialog">
                  <div class="modal-dialog" role="document">
                      <div class="modal-content">
                          <div class="modal-header">
                              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                  <span aria-hidden="true">&times;</span>
                              </button>
                              <h4 class="modal-title">Select a Country</h4>
                          </div>
                          <div class="modal-body">
                              <div class="alert alert-info">
                                  <strong>Placeholder</strong> Here is a table to select an existing country
                              </div>
                              <button class="btn btn-success btn-block" id="createCountryButton">Create new country</button>
                              <button class="btn btn-primary">OK (not implemented)</button>
                              <button class="btn btn-default modalCloseButton"
                                      data-modalid="SelectCountry">Cancel</button>
                          </div>
                      </div>
                  </div>
              </div>
              <!-- Select Country END -->
              <!-- Create Country -->
              <div id="CreateCountry" class="modal fade fullScreen" tabindex="-1" role="dialog">
                  <div class="modal-dialog" role="document">
                      <div class="modal-content">
                          <div class="modal-header">
                              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                  <span aria-hidden="true">&times;</span>
                              </button>
                              <h4 class="modal-title">Create Country</h4>
                          </div>
                          <div class="modal-body">
                              <div class="alert alert-info">
                                  <strong>Placeholder</strong> Here is the form to create a country
                              </div>
                              <button class="btn btn-primary">OK (not implemented)</button>
                              <button class="btn btn-default modalCloseButton"
                                      data-modalid="CreateCountry">Cancel</button>
                          </div>
                      </div>
                  </div>
              </div>
              <!-- Create Country END -->

            </div>
        </div>
    </div>
</div>

<button class="btn btn-primary btn-block" id="openModal">Open Modal</button>

JS:
var zIndex = 10000;
    // Displys the given modal on top of everything else
    // modal: The modal to display as jQuery object
    // Does not work => remove thw first two lines to see the problem
    function displayModalOnTop(modal) {
    // remove me
    modal.modal('show');
    return;
    // end remove
        zIndex += 2;
        modal.css('z-index', zIndex);
        modal.modal('show');
        setTimeout(function () {
            $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
        }, 0);
    }

$(function(){
  $('#openModal').on('click', function(){
      displayModalOnTop($('#CreateAddress'));
  });

  // generic close modal handler
  $('.modalCloseButton').on('click', function(){
      var $this = $(this);
      var modalId = $this.attr('data-modalid');
      $('#' + modalId).modal('hide');
  })

  // Select city click
  $('#selectCityButton').on('click', function(){
      displayModalOnTop($('#SelectCity'));
  });

  // Create city click
  $('#createCityButton').on('click', function(){
      displayModalOnTop($('#CreateCity'));
  });

  // Select country click  
  $('#selectCountryButton').on('click', function(){
      displayModalOnTop($('#SelectCountry'));
  });

  // Create country click
  $('#createCountryButton').on('click', function(){
      displayModalOnTop($('#CreateCountry'));
  });
});

CSS:
.modal.fullScreen {
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-top: 48px;
}
.modal.fullScreen .modal-content {
  height: auto;
  min-height: 100%;
  border-radius: 0;
}
.modal.fullScreen .modal-body.noPadding {
  padding: 0;
}
.modal.fullScreen .modal-dialog {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
}
.modal.fullScreen .modal-header {
  background-color: #3276b1;
  color: #fff;
}
.modal.fullScreen .modal-header .close {
  color: #FFF;
  text-decoration: none;
  cursor: pointer;
  opacity: 0.4;
  font-size: 30px;
}
.modal.fullScreen .modal-header .close:hover {
  opacity: 1 !important;
}

A:

The problem was that the modal covered the hole screen. The backdrop was visible due to the margin of the modal but was not clickable because it was totally covered by the modal.
Removing the margin from the modal and adding it to the modal dialog fixed the problem.

