소스 검색

add reference to original option element in the data when attached to select. fixes #171

Igor Vaynberg 13 년 전
부모
커밋
6b736669d2
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      select2.js

+ 2 - 2
select2.js

@@ -626,10 +626,10 @@
                         var group;
                         if (element.is("option")) {
                             if (query.matcher(term, element.text())) {
-                                collection.push({id:element.attr("value"), text:element.text()});
+                                collection.push({id:element.attr("value"), text:element.text(), element: element.get()});
                             }
                         } else if (element.is("optgroup")) {
-                            group={text:element.attr("label"), children:[]};
+                            group={text:element.attr("label"), children:[], element: element.get()};
                             element.children().each2(function(i, elm) { process(elm, group.children); });
                             if (group.children.length>0) {
                                 collection.push(group);