Select2 disables click events by default, and for now, you should use a workaround to achieve the desired results. Here is an example of how I did this, thanks to the resources below. This will not work unless you re-create the variable instance with the return value .data ('select2')
First add the class to your links:
<a href="#" class="detail-link">hello</a>
Then you should listen for the onSelect event for Select2
var search = $("#searchBox");
search.select2({
placeholder: "Search...",
allowClear: true,
minimumInputLength: 3,
maximumSelectionSize: 1,
escapeMarkup: function(m) { return m; },
ajax: { blah blah blah },
formatResult: window.App.formatFunction
});
search= search.data('select2');
search.onSelect = (function(fn) {
return function(data, options) {
var target;
if (options != null) {
target = $(options.target);
}
if (target && target.hasClass('detail-link')) {
window.location = target.attr('href');
} else {
return fn.apply(this, arguments);
}
}
})(search.onSelect);
//JFiddle , .data('select2')
EDIT: - fooobar.com/questions/227057/...