dom event "select2:select" does not fire on selection with keyboard enter in select2 4.0

510 Views Asked by At

I implemented select2 on this startpage: http://www.bier-in-aktion.at - the select field is positioned below the big logos.

the select menu includes beers. i want to fire the select2.select dom event on an option select (like the documentation of 4.0 says it does) to forward the user to the beer detail page, which i solve with defining a "window.location" forward in the code that gets executed when the "select2:select" event is fired. Here's the code doing this:

  $("#beersSelectOptions").select2().on("select2:select", function() {

      //get clicked element
      var clickObject = $(event.target).data();

      //define route + conduct url forward
      var domain = document.domain;
      var brand_uri = clickObject.data.element.attributes[2].value;
      var beer_uri = clickObject.data.element.attributes[3].value;
      location.href='/'+brand_uri+'/'+beer_uri;

   });

BUT: the event fires only on mouse click, not on keyboard enter of the option.

am I using it incorrect? does anybody know how to fix this?

0

There are 0 best solutions below