opensas
opensas

Reputation: 63525

Can't catch select2-* events using select2 combo

I must be missing something, because I'm trying to catch select2 events but can't seem to make it.

HTML:

<body id="body">
  <input type='text' />
  <br />
  <input type='text' id='e11' />
  <br />
  <input type='text' />
  <br />
  <div id='out' />
</body>

JavaScript:

$("#e11").select2({
  placeholder: 'select and item',
  data: [{id: 0, text: 'story'},{id: 1, text: 'bug'},{id: 2, text: 'task'}]
});

$("#e11")
  .on("select2-focus", function(e) { log("select2-focus");})
  .on("select2-blur",  function(e) { log("select2-blur");})
  .on("change",        function(e) { log("change");})
  .on('focus',         function(e) { log('focus');
});

The only event I catch is the change event.

What am I missing?

Here's a fiddle showing it in action.

Upvotes: 1

Views: 1079

Answers (2)

opensas
opensas

Reputation: 63525

It seems like there's an incompatibility with select2 3.3.2 and jQuery 1.9.1

upgrading to select2 3.4.0 (the latest version) solved the problem

unfortunately, select2-3.4.0 is not yet available on any cdn (so I can update the fiddle)

Upvotes: 1

Esger
Esger

Reputation: 1417

Select2.js is meant to replace <select> elements with <option>s. Not for <input> afaik.

Upvotes: 0

Related Questions