var TurbolinksAdapter = {
  beforeMount: function(){
    document.addEventListener('turbolinks:before-cache', () => {
      this.$destroy();
    });

    this.$originalEl = this.$el.outerHTML;
  },
  destroyed: function() {
    this.$el.outerHTML = this.$originalEl;
  }
};

export default TurbolinksAdapter;

function destroyVue() {
  this.$destroy();
  document.removeEventListener('turbolinks:before-cache', destroyVue.bind(this))
}

var TurbolinksAdapter = {
  beforeMount: function(){
    document.addEventListener('turbolinks:before-cache', destroyVue.bind(this))
    this.$originalEl = this.$el.outerHTML;
  },
  destroyed: function() {
    this.$el.outerHTML = this.$originalEl;
  }
};

export default TurbolinksAdapter;

Remove event listener automatically on page change
Remove event listener automatically on page change
