I'm using Select2 to enhance my <select>
input. I populate the <options>
with coldfusion and sql. I want to use formatNoMatches
to add the option if there are no matches in the user search. I don't want to use a multiple select because it does not work with my coldfusion, plus it would be much simpler to simply add a click event to formatNoMatches
.
Somewhere in select2.js, there is code that is stopping mouse events from occurring for formatNoMatches
. Is there a way to hack it that will allow mouse events?
$(".select").select2({
allowClear: true,
blurOnChange: true,
openOnEnter: false,
formatNoMatches: function(term) {
return "<a href='#' onclick='alert('" + term + "');'"
+ "id='newClient'>Add New Client</a>";
}
});
I can't get the above code to alert anything.
stopPropagation()
in the plugin and certainely one of them prevents to use a link onNoMatches
. I have the same problem. – Rolan