title: show modal window using javascript
body: <p>I want to display modal dialog based on a bool variable in javascript. The best would be to bind bool variable to some attribute (e.g. visibility) and when the variable is true, modal dialog appears and if it is false it will be dismised ("background" site will be displayed).</p>
  
  <p>I use <a href="https://bootstrapious.com/p/bootstrap-4-dark-admin-premium" rel="nofollow noreferrer">this bootstrapious</a> template with jquery 1.9.1 and bootstrap 3.3.7. I found some related topics in the internet, I tried to use them:</p>
  
  <p>1) at first I used some attribute of modal dialog div, like visibility, where I would use my code that will output true or false. I meant something like using <code>style="visibility:hidden"</code>/<code>visible</code>, but when it was set to visible it didn't appear automatically. </p>
  
  <p>2) using hints from getbootstrap.com: <code>$('#myModal').modal('show')</code> and other variants appearing onload or on document ready</p>
  
  <pre><code>$(document).ready(function(){
     jQuery.noConflict();
     $('#myModal').modal('show');
  });
  </code></pre>
  
  <p>or</p>
  
  <pre><code>    $(document).on('load',function(){
          $('.modal').modal('show');
  });
  </code></pre>
  
  <p>none of the works.</p>
  
  <p>Finally I would use something like</p>
  
  <pre><code>if(myVar == true)
       modal.show()
  else
       modal.hide()
  </code></pre>
  
  <p>Is it even possible to realize that?
  Any help is appreciated!</p>