[Vuejs]-Select option doesn't update in Vue JS with Chosen plugin And API

0👍

Due to reactivity limitations in JS, Vue cannot detect changes made to an array.

You can either use the Vue.set(array, index, item) to set the value of a specific index in the array to a new value OR in your case change the reference of your users.data array to a new array as follows:

$.get("demo_test.php", function(res, status){
    ...
    var newUserData = res.users;
    app.users.data = [...app.users.data, newUserData];
    ...
  });

The above code should trigger the change as app.users.data now points to a new array that’s a copy of the existing array with the new item added to it.

Leave a comment