title: How to toggle objects on a canvas with selector?
body: <p>I have a selector with 2 options. Option 1 should only display the IText and option 2 should NOT display the IText but SHOULD display the image, and some extra info (the div). How can I make the selector toggle the canvas objects so that I can switch back and forth, instead of having everything load at once as it is? <a href="http://jsfiddle.net/14ynjq73/" rel="nofollow noreferrer">Here is a fiddle of what I have</a>.</p>
  
  <p>I'm using fabric.js version 1.7.20, if it matters.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var canvas = new fabric.Canvas('c');
  canvas.setHeight(600);
  canvas.setWidth(637);
  
  $(function() {
    $('#selector').change(function() {
      $('.options').hide();
      $('#' + $(this).val()).show();
    });
  });
  
  // some IText, intended for option one only
  canvas.add(new fabric.IText('Some Text That Should Only\nBe Displayed with Option One', {
    left: 175,
    top: 55,
    fontSize: 27,
  }));
  
  // frame image, intended for option two only
  fabric.Image.fromURL('https://i.imgur.com/DrzSWSa.png', function(img) {
    isImageLoaded = true;
    oImg = img.set({
      selectable: false,
      evented: false,
    }).scale(0.5);
    canvas.add(oImg).renderAll();
    canvas.sendToBack(oImg);
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>canvas {
    border: 1px solid #dddddd;
    margin-top: 10px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.7.20/fabric.min.js"&gt;&lt;/script&gt;
  &lt;Select id="selector"&gt;
     &lt;option value="one"&gt;Option One&lt;/option&gt;
     &lt;option value="two"&gt;Option Two&lt;/option&gt;
  &lt;/Select&gt;
  &lt;div id="two" class="options" style="display:none"&gt;Display with Option 2 Selected&lt;/div&gt;
  
  &lt;canvas id="c"&gt;&lt;/canvas&gt;</code></pre>
  </div>
  </div>
  </p>