title: Uncaught Error: cannot call methods on modal prior to initialization; attempted to call method 'openModal'
body: <p>I am making this model using javascript in magento 2. And its giving this error . dont know what is wrong with that It was working for few days. </p>
  
  <pre><code>&lt;div id="custom-popup-modal"&gt;
  &lt;div class="col-sm-6"&gt;
  &lt;div class="static_content"&gt;
  &lt;h5 class="min-title-bold"&gt;JOIN THE PARTY&lt;/h5&gt;
  &lt;h2 class="min-title-large"&gt;GET 15% OFF YOUR FIRST ORDER*&lt;/h2&gt;
  &lt;p class="small-content"&gt;Subscribers only discounts, first look at new products, and cutting-edges tips&lt;/p&gt;
  {{block class="Magento\Newsletter\Block\Subscribe" name="static.newsletter" template="Magento_Newsletter::subscribe.phtml"}}
  &lt;p class="micro-text"&gt;*Promo code will be emailed to the address you enter, New subscribers only&lt;/p&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="col-sm-6 img-section"&gt;&lt;img src="{{media url="wysiwyg/image-email_1.gif"}}" alt="" /&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;script type="text/javascript" xml="space"&gt;// &lt;![CDATA[
  // 
  // 
  // 
      require(['jquery','Magento_Ui/js/modal/modal'],
          function($,modal) {
              var options = {
                  type: 'popup',
                  responsive: true,
              };
              var popup = modal(options, $('#custom-popup-modal'));
              $( document ).ready(function() {
                  $('#custom-popup-modal').modal('openModal');
              });
          }
      );
  // 
  // 
  // 
  // ]]&gt;&lt;/script&gt;
  </code></pre>