Can anybody explain how the modal windows work?

I want to make a new modal window of a new view anybody done that before?

A modal window is loaded via AJAX request as simple HTML. After it’s loaded the code in the modal is parsed by the browser where the modal(‘show’) command displays the modal.

The modal itself has another AJAX function inside which handles all the functionality of the modal like selecting form fields or submitting the form.

    I picked a part the code needed 
    
    this goes in what ever view.php you want  
    
    <?php if (isset($modal_signature)) {
        echo $modal_signature;
    } ?>
    
   <a href="#add-signature" class="btn btn-default" data-toggle="modal">  </a>
    
    
    add this to controller file  signature.php
    
    $this->layout->buffer('modal_signature', 'signatures/modal_signature');
    $this->layout->render();
    
    this code goes in to your modal view file  called modal_signature.php
    
    <div id="add-signature" class="modal col-xs-12 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2"
         role="dialog" aria-labelledby="modal_add_signature" aria-hidden="true">
    </div>