[Vuejs]-JQuery has outdated data after vue changes

0👍

The best way I found to solve this problem was actually very simple.

I just had to destroy the chosen element before initializing again.

$('#modelSelect').chosen("destroy");
partAPI.getModels(newBrandId).then((result) => {
  models.value = result;

  nextTick(() => {
    $("#modelSelect").chosen({ allow_single_deselect: true, width: "100%" });
  });
});

This issue can also be fixed by wrapping chosen element in a vue container.

The Jquery element still has outdated data but this way the chosen is created with the new data instead.

Leave a comment