Reputation: 1178
I am using a plugin for my selectors. It is called Chosen. I am trying to add a listener to any of the following but I feel that the plugin is preventing anything from happening. Ideally I wanted to add an event so that everytime someone adds a "tag" to a multiple select group a method gets called. However this is proving to be more difficult then it should be. So far I have have tried the following:
//detect when input field changes
$(".chzn-choices").find("input").change(function () { alert("lol I worked"); });
//detect when option is clicked (I dont think this works as a click event is already binded to these and something is preventing the default
$(".chzn-drop").delegate("li", "click", function () { alert("clicked"); });
Anyone have any ideas what I could try here?
Upvotes: 1
Views: 2888
Reputation: 46
see http://harvesthq.github.com/chosen/
Form Field Change
When working with form fields, you often want to perform some behavior after a value has been selected or deselected. Whenever a user selects a field in Chosen, it triggers a "change" event* on the original form field. That let's you do something like this:
$("#form_field").chosen().change( … );
Upvotes: 3