We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fcea152 commit f63a10cCopy full SHA for f63a10c
1 file changed
select2.js
@@ -1660,6 +1660,23 @@ the specific language governing permissions and limitations under the Apache Lic
1660
if ($.isFunction(callback))
1661
callback({id: selected.attr("value"), text: selected.text(), element:selected});
1662
};
1663
+ } else if ("data" in opts) {
1664
+ // install default initSelection when applied to hidden input and data is local
1665
+ opts.initSelection = opts.initSelection || function (element, callback) {
1666
+ var data,
1667
+ id = element.val();
1668
+
1669
+ $.each(opts.data, function(k, v){
1670
+ if(id == opts.id(v)) {
1671
+ data = v;
1672
+ return false;
1673
+ }
1674
+ });
1675
1676
+ if ($.isFunction(callback)) {
1677
+ callback(data);
1678
1679
+ };
1680
}
1681
1682
return opts;
0 commit comments