I want check if a user click on select2 close button or only it's triggered a change event. This is my select2 input:
<%= hidden_field_tag :query, params[:query], :id => "query_txt" %>
On my coffeescript file:
$('#query_txt').select2(
#select2 options here, ajax, initSelection...etc
#
#
#
$("#query_txt").on "change", (e) ->
if ($(".select2-search-choice-close").click ->)
console.log "click on close"
)
The problem is that if I click on suggestions text I can see the text "click on close" on my console.
In other words, If you click on x/remove button as in this image:
the same behavior happens if you click in suggestions text as in this image:
You can see a example code in http://jsfiddle.net/nqWNJ/9/
My question is how I can know when a user clicks on suggestions text or click on the close button.
Thank you