[Vuejs]-VueJS Resource reload content

2👍

Vue.resourse have no relation to this problem
becouse html string from json isn’t compiled.

Here a little test based on your example:

<body>
    <a href='#' v-on:click.prevent='getLink' v-text="button"></a>
    <div v-el:sample></div>
</body>
var test = new Vue({
  el: 'body',

  data: {
    button: 'Lorem sss',
  },

  methods: {
    getLink: function(){
      var r = Math.floor(Math.random() * (4 - 1)) + 1;
      this.$set('button', ['','btn1','btn2','btn3'][r] );
    },

    getCompiled: function() {
      $(this.$els.sample).empty()
      var element = $(this.$els.sample).append("<a href='#' v-on:click.prevent='getLink'>{{ button }}</a>");
      this.$compile(element.get(0));
      $(this.$els.sample).prepend('<p>Compiled button:</p>')
    }
  },

  ready: function() {
    this.getCompiled();
  }
})

jsfidle

👤Alex

Leave a comment