From fb78905c6a344d1674387a3a24cb9bfc5c2f0322 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Tue, 26 Mar 2013 08:58:55 -0700 Subject: [PATCH] fix val() description in the docs. fixes #1091 --- index.html | 5 ++--- select2-latest.html | 3 ++- select2-master | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index cfdbe97d..33c682d7 100644 --- a/index.html +++ b/index.html @@ -1469,15 +1469,14 @@ $("#select").select2({

val method invoked on a single-select with an unset value will return "", while a val method invoked on an empty multi-select will return []

- Example:
alert("Selected value is: "+$("#e8").select2("val")); $("#e8").select2("val", {id:"CA", text:"Califoria"});
+ Example:
alert("Selected value is: "+$("#e8").select2("val")); $("#e8").select2("val", "CA"});
+

Notice that in order to use this method you must define the initSelection function in the options so Select2 knows how to transform the id of the object you pass in val() to the full object it needs to render selection. If you are attaching to a select element this function is already provided for you.

data

Gets or sets the selection. Analogous to val method, but works with objects instead of ids.

data method invoked on a single-select with an unset value will return null, while a data method invoked on an empty multi-select will return []

- -

destroy

diff --git a/select2-latest.html b/select2-latest.html index a1ee4a79..e20460ed 100644 --- a/select2-latest.html +++ b/select2-latest.html @@ -1527,7 +1527,8 @@ $("#select").select2({

val method invoked on a single-select with an unset value will return "", while a val method invoked on an empty multi-select will return []

- Example:
alert("Selected value is: "+$("#e8").select2("val")); $("#e8").select2("val", {id:"CA", text:"Califoria"});
+ Example:
alert("Selected value is: "+$("#e8").select2("val")); $("#e8").select2("val", "CA"});
+

Notice that in order to use this method you must define the initSelection function in the options so Select2 knows how to transform the id of the object you pass in val() to the full object it needs to render selection. If you are attaching to a select element this function is already provided for you.

data

diff --git a/select2-master b/select2-master index 5782e07f..f9f76d8b 160000 --- a/select2-master +++ b/select2-master @@ -1 +1 @@ -Subproject commit 5782e07ff8da2700ceffd3db64a20846be21453d +Subproject commit f9f76d8b4c72605baa937e3749f25187f0cce17f