From 855281feea9967ea5cc5d1d6c4fceb9f80baaede Mon Sep 17 00:00:00 2001 From: Andrew Velis Date: Tue, 8 Oct 2013 23:40:03 -0700 Subject: [PATCH] Documentation of select2-removing event feature. Addition of documentation highlights the new event's purpose and usage. Code has been added to the "Events Log" section of the documentation to illustrate usage of the event in practice. --- select2-latest.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/select2-latest.html b/select2-latest.html index 66626810..77a0bd71 100644 --- a/select2-latest.html +++ b/select2-latest.html @@ -669,6 +669,7 @@ $("#e11") .on("select2-close", function() { log("close"); }) .on("select2-highlight", function(e) { log ("highlighted val="+ e.val+" choice="+ JSON.stringify(e.choice));}) .on("select2-selecting", function(e) { log ("selecting val="+ e.val+" choice="+ JSON.stringify(e.choice));}) + .on("select2-removing", function(e) { log ("removing val="+ e.val+" choice="+ JSON.stringify(e.choice));}) .on("select2-removed", function(e) { log ("removed val="+ e.val+" choice="+ JSON.stringify(e.choice));}) .on("select2-loaded", function(e) { log ("loaded (data property omitted for brevitiy)");}) .on("select2-focus", function(e) { log ("focus");}) @@ -680,6 +681,7 @@ $("#e11_2") .on("select2-close", function() { log("close"); }) .on("select2-highlight", function(e) { log ("highlighted val="+ e.val+" choice="+ JSON.stringify(e.choice));}) .on("select2-selecting", function(e) { log ("selecting val="+ e.val+" choice="+ JSON.stringify(e.choice));}) + .on("select2-removing", function(e) { log ("removing val="+ e.val+" choice="+ JSON.stringify(e.choice));}) .on("select2-removed", function(e) { log ("removed val="+ e.val+" choice="+ JSON.stringify(e.choice));}) .on("select2-loaded", function(e) { log ("loaded (data property omitted for brevitiy)");}) .on("select2-focus", function(e) { log ("focus");}) @@ -1717,6 +1719,20 @@ $("#select").select2({

For the clear button to be visible the allowClear option needs to be true.

+
+
+

select2-removing

+

Fired when a choice is about to be removed in the dropdown/input, but before any removal of the choice has been made. + This event is used to allow the user to reject removal by calling event.preventDefault()

+

+

The event object contains the following custom properties: +

+
val
The id of the removing choice object.
+
object
The choice object about to be removed.
+
+

+
+

select2-removed