show item request form when an unknown item is selected in select2

You are using change:select but that is not a select2 event. The closest event to that is change.select2 but that is not what you want. The event you want is select2:select, which occurs whenever a result is selected.

Given your existing code, you’ve already set isTag to true so the rest of your code works as you expect:

}).on("select2:select", function(e) {
  var data =;
  var requestForm = document.querySelector('form');
  if (data.isTag) {
    console.log('local tag selected', data); = 'block';
  } else { = 'none';

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top