title: leaflet.draw trash button delete all polygons and save
body: <p>Using javascript, how can I alter the leaflet.draw "Trash" button to delete all polygons that have been drawn and automatically save. Below is the code I've implemented but it is a complete hack. It removes the active polygon, but after I delete an object once I begin to get errors in the console when I click the "Trash" icon like <code>NotFoundError: Node was not found</code> and <code>TypeError: this._deletedLayers is null</code></p>
  
  <pre><code>map.on('draw:editstart', function (e) {
              if(e.handler == 'remove' &amp;&amp; typeof drawnItem != 'undefined' &amp;&amp; drawnItem !== null){
                  if(window.console) window.console.log('Drawing deleted...');
                  if(typeof drawnItem != 'undefined' &amp;&amp; drawnItem !== null){
                      drawnItems.removeLayer(drawnItem);
                  }
                  $('.leaflet-draw.leaflet-control .leaflet-draw-actions').hide();
                  $('.leaflet-popup-pane .leaflet-draw-tooltip').remove();
              }
          });
  </code></pre>