title: Set Flatpickr defaultDate through programmaticaly
body: <p>I use Flatpickr from Wix Code thru an html-component. The communication, using postMessage/onMessage works perfectly. I can send a selected date from datepicker (html-component) back to Wix. Also, I can send to the component, from Wix. The problem is that I postMessage a valid date, it arrives perfectly, but then I need to set it as a flatpickr defaultDate property. And that, I cannot work out.
  The line</p>
  <pre><code>$(&quot;#startDate&quot;).flatpickr.defaultDate = event.data;
  </code></pre>
  <p>or</p>
  <pre><code>$(&quot;#startDate&quot;).defaultDate = event.data;
  </code></pre>
  <p>does not set the defaultDate. <code>event.data</code> holds a valid date to set.</p>
  <p>It´s a syntax problem, I know, but I cannot figure it out.</p>
  <p>Code below:</p>
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.2.3/flatpickr.css&quot;&gt;
     &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.2.3/themes/material_green.css&quot;&gt; 
    &lt;/head&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
      window.onmessage = (event) =&gt; {
      if (event.data) {
          $(&quot;#startDate&quot;).flatpickr.defaultDate = event.data;
      }
  };
  
  function sendLoadMessage () {
      window.parent.postMessage(&quot;LoadOk&quot;, &quot;*&quot;);
  }
  &lt;/script&gt;
  &lt;body onload=&quot;sendLoadMessage ();&quot; style=&quot;font-family: verdana;background-color:white;margin:0;padding:0&quot;&gt;
    &lt;div&gt;
      &lt;input type=&quot;text&quot; hidden=&quot;true&quot; id=&quot;startDate&quot; data-input&gt;
  &lt;/div&gt;
    
      &lt;!-- jQuery --&gt;
    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js&quot;&gt;&lt;/script&gt;
    &lt;!--  Flatpickr  --&gt;
    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.2.3/flatpickr.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;https://npmcdn.com/flatpickr/dist/l10n/es.js&quot;&gt;&lt;/script&gt;
  &lt;script&gt;
  $(&quot;#startDate&quot;).flatpickr({
      enableTime: false,
      dateFormat: &quot;d/m/Y&quot;,
      inline: true,
      locale: &quot;es&quot;,  
  &lt;!-- defaultDate : &quot;01/05/2018&quot;,--&gt;
      onChange: function(selectedDates, dateStr, instance) {
          window.parent.postMessage(selectedDates, &quot;*&quot;);
      },
  });
  
  
  &lt;/script&gt;
  &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>