From bae34d4f8acd0b38986ccea7284a1514c737d799 Mon Sep 17 00:00:00 2001 From: Stan Senotrusov Date: Mon, 2 May 2016 15:26:43 +0200 Subject: [PATCH] Add event handler example to documentation on how to programmatically access a selection data. --- docs/_includes/options/data/selection-access.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/_includes/options/data/selection-access.html b/docs/_includes/options/data/selection-access.html index 14149762..2fd3d6b8 100644 --- a/docs/_includes/options/data/selection-access.html +++ b/docs/_includes/options/data/selection-access.html @@ -35,6 +35,16 @@ $('select').select2({ // Retrieve custom attribute value of the first selected element $('select').find(':selected').attr('data-custom-attribute') +{% endhighlight %} + +

+ In addition, properties/values from source data objects can ba accessed from within event handler: +

+ +{% highlight js linenos %} +$('select').on('select2:select', function (event) { + console.log(event.params.data) +}); {% endhighlight %} \ No newline at end of file