From 458c4692145fb329f7ddc2763d291031fc762aca Mon Sep 17 00:00:00 2001 From: Ken Earley Date: Fri, 19 Jul 2013 13:38:49 -0500 Subject: [PATCH 1/3] Added events example and descriptions to documentation --- public/options.html | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/public/options.html b/public/options.html index b91bb488f8a..b9f2a94a1a4 100644 --- a/public/options.html +++ b/public/options.html @@ -157,6 +157,44 @@

Example:

+ +

Events

+

Chosen fires events to which you can attach listeners.

+ +

Example:

+ +
+  $('.chzn-select').bind('change', function(evt, params) {
+    do_something(evt, params);
+  });
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
EventDescription
changeChosen triggers the standard DOM event whenever a selection is made (it also includes a selected or deselected parameter that tells you which option was changed).
liszt:readyafter Chosen has been fully instantiated.
liszt:maxselectedtriggered if max_selected_options is set and that total is broken.
liszt:showing_dropdowntriggered when the dropdown is opened
liszt:hiding_dropdowntriggered when the dropdown is closed
+
From 944b67c085c961265d0d799916eae7a8595c1e94 Mon Sep 17 00:00:00 2001 From: Ken Earley Date: Fri, 19 Jul 2013 13:54:45 -0500 Subject: [PATCH 2/3] Updated events documentation --- public/options.html | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/public/options.html b/public/options.html index b9f2a94a1a4..8b5c1b2bf54 100644 --- a/public/options.html +++ b/public/options.html @@ -159,12 +159,12 @@

Example:

Events

-

Chosen fires events to which you can attach listeners.

+

Chosen triggers a number of standard and custom events on the original select field.

Example:

-  $('.chzn-select').bind('change', function(evt, params) {
+  $('select').on('change', function(evt, params) {
     do_something(evt, params);
   });
 
@@ -175,7 +175,10 @@

Example:

change - Chosen triggers the standard DOM event whenever a selection is made (it also includes a selected or deselected parameter that tells you which option was changed). + +

Chosen triggers the standard DOM event whenever a selection is made (it also includes a selected or deselected parameter that tells you which option was changed).

+

Note: in order to use change in the Prototype version, you have to include the Event.simulate class. The selected and deselected parameters are not available for Prototype.

+ liszt:ready @@ -187,11 +190,11 @@

Example:

liszt:showing_dropdown - triggered when the dropdown is opened + triggered when Chosen's dropdown is opened. liszt:hiding_dropdown - triggered when the dropdown is closed + triggered when Chosen's dropdown is closed. From 7be5a7ba021ebcf0d4c6325d834ed24708c8ee23 Mon Sep 17 00:00:00 2001 From: Ken Earley Date: Fri, 19 Jul 2013 14:15:21 -0500 Subject: [PATCH 3/3] Added info about params sent with events --- public/options.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/options.html b/public/options.html index 8b5c1b2bf54..93f79df27fb 100644 --- a/public/options.html +++ b/public/options.html @@ -176,25 +176,25 @@

Example:

change -

Chosen triggers the standard DOM event whenever a selection is made (it also includes a selected or deselected parameter that tells you which option was changed).

+

Chosen triggers the standard DOM event whenever a selection is made (it also sends a selected or deselected parameter that tells you which option was changed).

Note: in order to use change in the Prototype version, you have to include the Event.simulate class. The selected and deselected parameters are not available for Prototype.

liszt:ready - after Chosen has been fully instantiated. + after Chosen has been fully instantiated (it also sends the chosen object as a parameter). liszt:maxselected - triggered if max_selected_options is set and that total is broken. + triggered if max_selected_options is set and that total is broken. (it also sends the chosen object as a parameter) liszt:showing_dropdown - triggered when Chosen's dropdown is opened. + triggered when Chosen's dropdown is opened (it also sends the chosen object as a parameter). liszt:hiding_dropdown - triggered when Chosen's dropdown is closed. + triggered when Chosen's dropdown is closed (it also sends the chosen object as a parameter).