title: Uncaught TypeError: Cannot read property 'alt' of null :Script stops
body: <p>when i get error Uncaught TypeError: Cannot read property 'alt' of null , my script works fine in browser but sometimes i see dragged object gets stucked when i inspect via device inscept i see belwo error</p>
  
  <p>my script stops executing how can i prevent that ??..</p>
  
  <p>see <a href="http://liveweave.com/GknZjq" rel="nofollow">http://liveweave.com/GknZjq</a></p>
  
  <pre><code>(function () {
      var canvas = new fabric.Canvas('canvas');
      var canvas_el = document.getElementById('canvas');
      var canvas1 = new fabric.Canvas('canvas1');
  
      var group;
      fabric.Image.fromURL('img/blank.png', function (img) {
          var img1 = img.set({
              left: 0,
              top: 0
          });
          fabric.Image.fromURL('img/blank.png', function (img) {
              var img2 = img.set({
                  left: 0,
                  top: 0
              });
              group = new fabric.Group([img1, img2], {
                  left: 0,
                  top: 0
              });
              canvas.add(group)
          });
      });
  
  
      fabric.Image.fromURL('img/blank.png', function (img) {
          var img1 = img.set({
              left: 0,
              top: 0
          });
          fabric.Image.fromURL('img/blank.png', function (img) {
              var img2 = img.set({
                  left: 0,
                  top: 0
              });
              group1 = new fabric.Group([img1, img2], {
                  left: 0,
                  top: 0
              });
              canvas1.add(group1)
          });
      });
  
  
  
      $(document).ready(function () {
  
  
  
          /* Define drag and drop zones */
          var $drop = $('#canvas-drop-area,#canvas-drop-area1'),
              $gallery = $('td &gt; #image-list li'),
              $draggedImage=null;
  
          /* Define the draggable properties */
          $gallery.draggable({
               helper: 'clone',
              start: function (e) {
              $draggedImage=event.target;
                  $drop.css({
                      'display': 'block'
                  })
              },
              stop: function () {
                  $(this).find('img').css({
                     /* 'opacity': 0.4 */
                  });
                  $drop.css({
                      'display': 'none'
                  });
                  $draggedImage=null;
              },
              revert: true
          });
  
          /* Define the events for droppable properties */
          $drop.droppable({
              over: function (event, ui) {
                  $(this).addClass('active');
              },
              drop: function (event, ui) {
                  var image =$draggedImage&amp;&amp; $draggedImage.src;
                  console.log($draggedImage.alt);
                  img_to_canvas(image,$draggedImage.alt,$(event.target).is("#canvas-drop-area")?1:2);
              },
              out: function (event, ui) {
                  $(this).removeClass('active');
              },
              deactivate: function (event, ui) {
                  $(this).removeClass('active');
              }
          });
  
      });
  
  
      var img_to_canvas = function(image,sendfront,checkcanvas) {
          var img = new Image();
          img.src = image;
          if(checkcanvas =='1'){
              if(sendfront=='top'){
                  fabric.util.loadImage(img.src, function (img) {
                      group.item(0).setElement(img);
                          canvas.renderAll();
                  }); 
              }else{
                  fabric.util.loadImage(img.src, function (img) {
                      group.item(1).setElement(img);
                          canvas.renderAll();
                  }); 
              }
              canvas.calcOffset();  
          }else{
              if(sendfront=='top'){
                  fabric.util.loadImage(img.src, function (img) {
                      group1.item(0).setElement(img);
                          canvas1.renderAll();
                  });         
              }else{
                  fabric.util.loadImage(img.src, function (img) {
                      group1.item(1).setElement(img);
                          canvas1.renderAll();
                  }); 
              }
              canvas1.calcOffset();       
          }
  
      }
  
  
  })();
  </code></pre>