diff --git a/example.html b/example.html index bd2d58c..7ea6e25 100644 --- a/example.html +++ b/example.html @@ -1198,6 +1198,26 @@
Chosen automatically sets the default field text ("Choose a country...") by reading the select element's title value. If no title value is present, it will default to "Select Some Option" or "Select Some Options" depending on whether the select is single or multiple. You can change these elements in the plug-in js file as you see fit.
<select title="Choose a country..." style="width:350px;" multiple class="chzn-select">
+
+ 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( … );
Note: Prototype doesn't offer support for triggering standard browser events. Event.simulate is required to trigger the change event when using the Prototype version.
+If you need to update the options in your select field and want Chosen to pick up the changes, you'll need to trigger the "liszt:updated" event on the field. Chosen will re-build itself based on the updated content.
+$("#form_field").trigger("liszt:updated");
Event.fire($("form_field"), "liszt:updated");
Using Chosen is easy as can be.
diff --git a/example.jquery.html b/example.jquery.html index 81d19c4..b534e52 100644 --- a/example.jquery.html +++ b/example.jquery.html @@ -1199,6 +1199,26 @@<select title="Choose a country..." style="width:350px;" multiple class="chzn-select">
+ 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( … );
Note: Prototype doesn't offer support for triggering standard browser events. Event.simulate is required to trigger the change event when using the Prototype version.
+If you need to update the options in your select field and want Chosen to pick up the changes, you'll need to trigger the "liszt:updated" event on the field. Chosen will re-build itself based on the updated content.
+$("#form_field").trigger("liszt:updated");
Event.fire($("form_field"), "liszt:updated");
Using Chosen is easy as can be.