def destroy
      @element = Element.find(params[:id])
      # Start by removing the element from the page
      page_element = PageElement.where(:element_id => @element.id, :page_id => @page.id).first
      page_element.destroy if page_element
      
      # If this element is not on any other pages, is not a question or has no answers, Destroy it
      if @element.reuseable? && (PageElement.where(:element_id => params[:id]).present? || @element.has_response?)
        @element.update_attributes(:question_grid_id => nil, :conditional_id => nil)
      else
        @element.destroy
      end

      respond_to do |format|
        format.js
      end
    end
def destroy
      @element = Element.find(params[:id])
      # Start by removing the element from the page
      page_element = PageElement.where(:element_id => @element.id, :page_id => @page.id).first
      page_element.destroy if page_element
      
      # If this element is not on any other pages, is not a question or has no answers, Destroy it
      if @element.reuseable? && (PageElement.where(:element_id => params[:id]).present? || @element.has_response?)
        @element.update_attributes(:question_grid_id => nil, :conditional_id => nil)
      else
        @element.destroy
      end

      respond_to do |format|
        format.js
      end
    end
DELETE /elements/1
 DELETE /elements/1.xml